Given two solutions to a problem, the one with less code is usually better.
Plite of the Programmer
Our job as programmers is to deliver value to customers. We deliver value by identifying needs, translating them into requirements, and writing code to meet those requirements. The difficulty of the task is compounded by the fact that requirements are constantly, unpredictably changing. Even after we finally ship, the story isn’t over. Code is a living thing that must be maintained, usually well beyond anyone's expectations.
Over the lifetime of a product, we will edit code 10x more than we write code, and we will read code 10x more than we edit it. Each token we add to our code may be read over 100 times. Every token we save could save up to 100 token-thoughts and 10 future edits. The key to our productivity is writing less code.
Why Count Tokens?
Tokens are the smallest meaningful element in code. Tokens are a more objective measure of code size since lines can have any number of tokens. Measuring tokens also ignores white-space and comments. Last, measuring tokens doesn't penalize using clear names. ‘Occupations’ is just as good a name under the token metrics as ‘occus’ or other hard to understand abbreviations.
Don't abbreviate words. Saving keystrokes only saves writing the code. It doesn't save edits or reading. Abriviations make reading harder. Since reading code dominates our time, abbreviations are a losing proposition. Only use shortened words if the shortened version is used at least as commonly in speech.
Measuring tokens is a simple, effective metric that lets us make decisions quickly and get on with solving problems and delivering value.
Why ‘Write Less Code’?
It's a simple concept with depth. Amateurs and masters both can apply and learn from it. A more accurate metric might be refactorability. We spend most of our time refactoring code, not writing it. Refactorability is the code-quality metric. It can be broken down into code size, clarity, and structure. Of the three, size is the only one that can be objectively measured, and while clarity and structure are important, both are usually improved by reducing code size. Refactorability is not something a novice will understand. ‘Write less code’ is an excellent guiding principle for all programmers.
How to Write Less Code
All other good coding practices essentially reduce code size. Two of the most important, and most often violated coding practices for reducing code-size are DRY and ZEN.
DRY
Don't. Repeat. Yourself. Don't you dare repeat yourself ;). The most problematic artifacts I've seen, both from novice and expert programmers, is code repetition. The big problem with repetition is it compounds the complexity of refactoring. Not only do we have to fix two or more things instead of one, but we have to understand how they all interact. Plus it bloats the code-base making it hard to understand.
DRY is a subtle art. The first, obvious level is ‘don't copy-paste your code,’ but as we level-up, we start to realize anything gzip might compress potentially violates DRY. The ultimate measure is, as always, refactorability. How many code-points need to change for a common refactor? Is there a way to reduce repetition to reduce the complexity of refactorability?
ZEN
Build it with Zero Extra Nuts (more commonly known as YAGNI). Because it is impossible to
predict future requirements, adding anything to our code that isn't strictly necessary to meet current requirements is not only a waste of time now, but it will haunt us for at least 10x future edits and 100x future reads.
It is fun to add cool features, but the master knows the only thing that matters is delivering value to the customer.
Write Less Code - Formalized
My hypothesis, and my experience, comes down to this:
- Given two different functions, modules or programs
- that both meet or exceed the problem's requirements, both correctness and performance
- the one with less tokens is always better
- as long as it doesn't sacrifice clarity.
The Practice of Writing Less Code
As with everything in life, writing less code is a practice. There is no point where we will master it. There is always another layer of deeper understanding. We are always learning how to make our code DRYer and more ZEN. We must constantly be looking for ways to meet requirements with less code.
After reading your more recent Jan 28th 2017 "Your SOUP is Leaking - Crafting Acronyms" article along with your thoughtful ZEN article and that principle's relationship to frameworks, I thought there might be a good alternative acronym to WLC that relates the two principles: ULC - Use Less Code.
ReplyDeleteThrough both thoughtful choices when sourcing 3rd party frameworks or modules and consideration in how to assemble or integrate them with your own code efforts, "Use" could include but also expand beyond just the code you create in a project.
While it is actually more pronounceable, I'm not sure a 'hulk' without the H sounds all that elegant. :)
I love that idea! WLC certainly isn't an elegant acronym by any stretch. "Hulk" means strength, not a terrible association with "ULC." I'll try it out.
DeleteI do like that "use" is more general than "write".
This was such a thorough and insightful read. i am glad i got to read it. you have a way with words and on top of that you are quite knowledgable. keep posting more
ReplyDeleteThanks! I'll try to write more.
DeleteWrite My Essay Thank you because you have been willing to share information with us. we will always appreciate all you have done here because I know you are very concerned with our.
ReplyDeleteIt was wondering if I could use this write-up on my other website, I will link it back to your website though.Great Thanks. write my essay for me
ReplyDeleteExcellent article. Very interesting to read. I really love to read such a nice article. Thanks! keep rocking. smart essay writing service
ReplyDeleteI’m happy I located this blog! From time to time, students want to cognitive the keys of productive literary essays composing. Your first-class knowledge about this good post can become a proper basis for such people. nice one do my essay
ReplyDeleteI read this article, it is really informative one. Your way of writing and making things clear is very impressive. Thank you for sharing such an informative article. thesis proofreading
ReplyDeleteI definitely enjoying every little bit of it. It is a great website and nice share. I want to thank you. Good job! You guys do a great blog, and have some great contents. Keep up the good work. Mua Tài khoản Grammarly Premium
ReplyDeleteHello everyone, We are Children's Furniture – Bao An Kids. Surely when you come to this page, you are looking for a professional children's interior design and construction unit to help you advise and choose for your family and baby to have a perfect and comfortable living space. the safest. Thank you very much for trusting and wanting to accompany Bao An Kids. nội thất trẻ em
ReplyDelete
ReplyDeleteBài viết rất hay! Quà tặng 24k chuyên cung cấp:
Đặt cúp đồng giá rẻ tại Hà Nội
Quà tặng vinh danh ở đâu chất lượng và uy tín
Hotline: 0866 866 711
Tan Binh valve has many years of experience in the field of industrial valves. Production meets DIN, BS, JIS standards… Tan Binh After more than 10 years of supplying materials for the water industry Our company is now a reliable partner for most companies providing water treatment systems in the local area. Hanoi as well as nationwide. van công nghiệp, Van cửa, van điện từ
ReplyDelete
ReplyDeleteBài viết bạn rất hay! Công ty cổ phần nội thất KFA hoạt động trong lĩnh vực thiết kế kiến trúc, nội thất. gợi ý cho bạn:
Bí quyết để có một không gian nội thất đẹp
Khám phá chi phí thi công nội thất trọn gói bao nhiêu?
Liên hệ để được tư vấn: ĐT: 0987.316.777
Today, the demand for modern sanitary products and equipment with preeminent features is increasing day by day. That's why many sanitary ware companies were born. To meet the essential needs of our customers. So what are the advantages of today's sanitary ware products? Let's find out detailed information with the Great World of Lights Showroom through the article below. More: https://bitly.com.vn/hfn52q
ReplyDeleteNhân Sâm Trường Thọ chuyên cung cấp các sản phẩm chính hãng chất lượng:
ReplyDeleteTrà hồng sâm Hàn Quốc
Hồng sâm Hàn Quốc 6 năm tuổi
Sản phẩm nhân sâm nhập khẩu trực tiếp từ Hàn Quốc có chất lượng đảm bảo, bao bì đóng gói đẹp mắt, sang trọng, vô cùng thích hợp để làm quà biếu, quà tặng.
Địa chỉ: 853 - 855 Nguyễn Kiệm, P.3, Q.Gò Vấp, TP.HCM.
Tel: +84 (28) 350.66666
Hotline: 090.77.999.88
ReplyDeleteCông ty Cổ Phần Công Nghệ và Giải Pháp EMS cung cấp :
Điều hòa chính xác
hệ thống nguồn một chiều
Điều hoà chính xác Liebert PEX
Liên Lạc theo SĐT: +84 24 7306 6226; +84 24 6687 4507
Nội thất Kfa đã có trên 10 năm kinh nghiệm trong thiết kế và thi công nội thất, được hàng nghìn khách hàng tin tưởng - đem đến sự hài lòng cho cả những khách hàng khó tính nhất
ReplyDeletePhong cách tropical trong thiết kế nội thất
Phong cách tropical là gì? Xem chi tiết ngay
Vách ngăn phòng khách là gì
Có Nên Sử Dụng Thảm Phòng Khách Hay Không
Máy tính Hải long là địa chỉ bán máy tính cũ uy tín chất lượng, có đội ngũ tư vấn chuyên sâu, am hiểu tường tận về từng chi tiết của máy tính. Đặc biệt, thời gian bảo hành cũng như chính sách đổi trả, không kém việc bạn mua máy mới 100% tại các siêu thị lớn.
ReplyDeleteĐịa chỉ: Số 9 ngách 109 ngõ 69a Hoàng Văn Thái, Thanh Xuân, Hà Nội
Điện thoại: 0972 105 943
Bài viết rất hay: Chúng tôi chuyên cung cấp các sản phẩm chất lượng
ReplyDeleteGiảo cổ lam giá rẻ tại Hà Nội
Bao nhiêu tiền 1 kg giảo cổ lam
Bài viết rất hay: Chúng tôi chuyên cung cấp các sản phẩm chất lượng
ReplyDeleteLều xông hơi mini giá rẻ tại Hà Nội
Lều xông hơi gia đình chất lượng
This is such a great resource that you are providing and you give it away for free. I love seeing blog that understand the value of providing a quality resource for free. nên mua điện thoại nào dưới 10 triệu
ReplyDelete
ReplyDeleteCông ty Tất Phú là nhà phân phối và trực tiếp nhập khẩu tấm xi măng CEMBOARD từ các hãng sản xuất uy tín, chất lượng từ nhiều nước khác nhau. Nắm trong tay gần 10 năm kinh nghiệm trong lĩnh vực cung cấp các dòng xi măng CEMBOARD chất lượng.
Báo giá tấm cemboard
Cung cấp tấm cemboard thái lan
Địa chỉ: Tầng 3, tòa nhà Shodex, số 245 Tam Trinh, Hoàng Mai, Hà Nội
Điện thoại: 024 66604646 – 0977 688 695
Xe nâng Đông Đô là địa chỉ chuyên cho thuê:
ReplyDelete- "Xe nâng komatsu 5 tấn".
- "Xe nâng Mitsubishi".
- "Xe nâng TCM cũ".
- "Xe nâng Toyota cũ".
Uy tín, giá rẻ nhất trên thị trường. Gọi ngay theo Hotline: 091.351.9810- 0912.018.299 để được hỗ trợ chi tiến nhất.
ReplyDeleteCứu hộ xe máy An Bình Motor nổi bật với các dịch vụ:
Cứu hộ xe máy – Xe moto nhanh nhất tại HCM giá rẻ
Cứu hộ xe máy hoàn kiếm - Sửa xe máy lưu động 15 phút là có
Cứu hộ xe máy thanh xuân - Sửa xe máy lưu động 15 phút là có
Hotline: 0941775222
Cửa chống ngập Minh Dũng là giải pháp tối ưu cho ngôi nhà của bạn. Với chi phí hợp lý, vận hành đơn giản, linh hoạt, hiệu quả chống ngập lên đến 99,99%.
ReplyDeleteHà Nội: số 21 Thọ Tháp - Cầu Giấy - Hà Nội
HCM : Mỹ Hòa - Trung Chánh - Hóc Môn - HCM
Hải Phòng: 212 - Ngô Gia Tự - Hải An - Hải Phòng
Đà Nẵng: 241/11 - Nguyễn Phước Nguyên - Thanh Khê - Đà Nẵng
Nam Định : 61 Nguyễn Hiền - TP Nam Định
Hotline: 0912.68.68.44/ 08.123.09.567
Thanks for publishing such best knowledge with us. You are doing such a great job. This info is very helpful for everyone. Keep it up. Thanks.Read more info about high quality dissertation services
ReplyDeleteCông Ty CP Thương Mại Kỹ Thuật Công Nghệ Đông Nam chuyên tư vấn,thiết kế, cung cấp, lắp đặt các thiết bị phòng cháy chữa cháy bao gồm: Hệ Thống Báo Cháy, Hệ Thống Chữa Cháy, Hệ Thống Chống Sét, Hệ Thống Báo Trộm.
ReplyDeleteXem thêm tại đây: Địa chỉ bán các thiết bị phòng cháy chữa cháy tốt nhất
Những thiết bị phong cháy chữa cháy bạn nên biết
Phone: 0917.911.114 - 0976.247.114
Dịch vụ cho thuê xe nâng giá rẻ
ReplyDeleteThuê xe nâng xếp dỡ máy móc
Dịch vụ nâng cẩu hàng nặng
Hotline: 091.351.9810- 0912.018.299
Tel: 024.3208.4888
This blog is basically related to programmer. They can get many tips form this article. While I am service provider of Pest Extermination Services in New York. My experts given you reliable service.
ReplyDelete
ReplyDeleteHey friend, it is very well written article, thank you for the valuable and useful information you provide in this post. Keep up the good work! FYI, Pet Care adda
can i use flipkart axis bank credit card anywhere, think again the power of knowing what you don t know pdf,mental health essay
Đá Mỹ Nghệ 35 là đơn vị cung cấp mẫu lăng mộ đá chất lượng hàng đầu hiện nay:
ReplyDeleteMẫu mộ đá đôi đẹp
Mẫu mộ đá đơn
Lăng mộ đá đẹp
Hotline: 0912.984.468
tấm xi măng cemboard thái lan
ReplyDeleteTấm Cemboard SCG Thái Lan
Tấm xốp Eco XPS Foam Panel
Tấm Cemboard Vĩnh Tường
Công ty Cổ Phần Thảo Dược Thiên Nhiên Việt Nam trân trọng truyền thống y học cổ truyền, chắt lọc từ những bài thuốc Đông y gia truyền, các bài thuốc cổ phương với những dược liệu quý hiếm từ thiên nhiên ban tặng kết hợp cùng công nghệ hiện đại của những nhà máy chế biến Dược liệu đạt tiêu chuẩn GMP để đưa ra những sản phẩm tốt, giá trị và mang đậm tính nhân văn đến với người sử dụng.
ReplyDelete*** Địa chỉ liên hệ ***
Trụ sở: Số 8, liền kề 12, Khu nhà ở cán bộ chiến sĩ Tổng cục 5 Bộ Công An, Yên Xá, Tân Triều, Thanh Trì, Hà Nội
Hotline: 0962.364.141
máy xông phòng ngủ
ReplyDeletemáy xông phòng
may xong tinh dau bang dien
Đơn vị chủ quản: Công ty cổ phần Doca
Số giấy phép: 0105898969, cấp ngày 23/05/2012
Hà Nội: Số 58,Giải Phóng, Đống Đa
Hồ Chí Minh: 34/35 Lữ Gia, Phường 15, Quận 11
Hotline: 0936387398 - 0943 979 989
Website: www.tinhdaucaocap.net
Email: ntdat29@yahoo.com
đá mỹ nghệ
ReplyDeleteMẫu lăng mộ đá
LĂNG MỘ ĐÁ - ĐÁ MỸ NGHỆ 35
Điện thoại: 0912984468
Email: phongthuy35@gmail.com
Địa chỉ: Làng nghề truyền thống đá mỹ nghệ Ninh Bình – Thôn Xuân Phúc,
xã Ninh Vân, huyện Hoa Lư, tỉnh Ninh Bình
*************
giá sàn bê tông siêu nhẹ bao nhiêu
ReplyDeletechi phí xây dựng nhà khung thép
Sàn bê tông nhẹ
Trụ sở chính : Địa chỉ : Thôn 2 - Yên Sở - Hoài Đức - Hà nội.
Văn phòng : Số 25 - Dốc Thành công - Ba Đình - Hà nội
While there are several types of construction projects, most of them fall into one of two categories: Building Construction and Industrial Construction. They can overlap, however each type requires its own process- including planning, designing, and executing (not to mention the different necessary permits). interior design
ReplyDeletemáy tính hà nội
ReplyDeletelắp đặt phòng game
Mua máy tính cũ
màn hình máy tính cũ
http://higssoftware.com/thesis-writing-services.php
ReplyDeleteHIGS- the best thesis writing or dissertation writing service in India, we explain to you about thesis writing, thesis writing definition and we offer endless thesis writing services or dissertation writing. We offer the best thesis writing help for all our clients across the globe. With us, you will definitely achieve the goal of success. Our team always gives our hands in providing help for thesis writing and we extend of horizons of knowledge in many places such as PhD thesis writing service in Chennai, Delhi, Hyderabad, Bangalore, Kerala, and more. With our great help in thesis writing service, you will get the best thesis writing help by meeting the high-level standard.
Điều hòa Funiki Inverter 18000 BTU 1 chiều HIC18TMU là một sản phẩm điều hòa Inverter được trình làng vào tháng 3/2022 với nhiều tính năng nổi bật. Sản phẩm được nhập khẩu nguyên chiếc từ Thái Lan/Malaysia và được bảo hành lên đến 24 tháng. Vua Điều Hòa là địa chỉ chuyên phân phối điều hòa Funiki chính hãng với giá tốt tại Hà Nội. Các sản phẩm của chúng đều được đảm bảo về chất lượng và chế độ bảo hành theo đúng cam kết của hãng. Hãy liên hệ ngay với Vua Điều Hòa để nhận được những ưu đãi tốt nhất.
ReplyDeleteĐiều hòa Funiki 2 chiều 24000BTU HSH24TMU sử dụng môi chất làm lạnh R32 vừa được tập đoàn Hòa Phát cho ra mắt vào đầu 2022 nhằm thay thế model cũ SH24MMC. Ngoài những tính năng củ, sản phẩm được trang bị nhiều tính năng mới tiến tiến mang đến cho người tiêu dùng trải nghiệm giá trị đích thực. Vua Điều Hòa chuyên phân phối các dòng điều hòa Funiki chính hãng với mức giá tốt. Hãy liên hệ ngay với chúng tôi để được hưởng những ưu đãi tốt nhất nhé!
ReplyDeleteKhi bé bị sốt hoặc gặp một số bệnh về hô hấp như ho, viêm mũi, đau họng,... thì các bà mẹ sẽ có xu hướng tắt máy lạnh trong nhà nhưng có bao giờ bạn thử tìm hiểu, trẻ em bị sốt cao có nên nằm điều hòa hay không?
ReplyDeletetấm xi măng cemboard thái lan
ReplyDeleteTấm Cemboard SCG Thái Lan
Tấm xốp Eco XPS Foam Panel
Tấm Cemboard Vĩnh Tường
NHÀ PHÂN PHỐI TẤM XI MĂNG CEMBOARD
Địa chỉ: Tầng 3, tòa nhà Shodex, số 245 Tam Trinh, Hoàng Mai, Hà Nội
Điện thoại: 024 66604646 - Hotline: 0928 688 695
Email: tatphu.com@gmail.com
Chiếc điều hòa Casper inverter 12000BTU GC-12IS32 sẽ là sự lựa chọn hàng đầu trong phân khúc điều hòa inverter giá rẻ có công suất 12000BTU. Sản phẩm được hãng Casper cho ra mắt vào năm 2021 hứa hẹn sẽ mà Model điều hòa thông dụng được nhiều tin tưởng lựa chọn. Tính năng iClean trên điều hòa Casper sẽ tự động làm sạch thông minh, giúp ngăn chặn sự hình thành vi khuẩn, nấm mốc ở bên trong dàn lạnh, tối ưu hoạt động, hạn chế số lần vệ sinh và tăng tuổi thọ của máy lạnh.
ReplyDeleteDựa trên thông tin bảng mã lỗi điều hòa Akito, bạn dễ dàng xác định được nguyên nhân và có biện pháp phù hợp khi gặp phải lỗi E0.
ReplyDeleteĐiều hòa Multi LG 2 chiều 42000BTU A5UW42GFA1 chính hãng được sản xuất và nhập khẩu trực tiếp từ nhà máy LG tại Thái Lan. Dàn nóng điều hòa Multi LG A5UW42GFA1 không chỉ được thiết kế hữu ích và mà còn giúp tiết kiệm không gian chắc chắn sẽ mang đến những trải nghiệm tốt nhất cho người dùng.
ReplyDeleteĐiều hòa Panasonic 9000BTU 2 chiều inverter XZ9XKH-8 được thiết kế với những đường nét thanh mảnh hiện đại. Điều hoà được nhập khẩu chính hãng từ Malaysia được với những công nghệ tiên tiến và hiện đại nhất. Điều hoà Panasonic hứa hẹn mang đến cho người dùng những sự trải nghiệm tuyệt vời trong cuộc sống.
ReplyDeleteViệc sử dụng điều hòa Aqua không đúng cách sẽ gây ra nhiều sự lãng phí, không tối ưu hóa năng suất hoạt động của điều hòa. Trong khi cách sử dụng điều hòa Aqua đúng sẽ giúp hệ thống vận hành ổn định hơn, chính xác, kéo dài tuổi thọ và tiết kiệm điện hơn rất nhiều. Hiểu được vấn đề mà đang số khách hàng đang gặp phải như trên, Vua Điều Hòa sẽ tổng hợp đầy đủ chi tiết cách sử dụng và gửi đến bạn ngay trong bài viết này.
ReplyDeleteDàn lạnh điều hòa Daikin Multi treo tường CTKM50RVMV là dàn lạnh treo tường tiêu chuẩn hệ Multi 1 chiều. Dàn lạnh Daikin CTKM50RVMV có thể kết nối được với tất cả các model dàn nóng 1 chiều Multi 2018 sử dụng gas R32: 3MKM52, 4MKM68, 4MKM80 và 5MKM100.
ReplyDelete