“Knowing when not to code” is possibly the most important skill of a programmer to learn. In practice, more code is almost always bad: it trashes the CPU cache, hogs the memory bus, uses up more CPU cycles, makes a security audit of the code harder, is harder to follow and maintain, and - last but not least - more code needs more documentation. The art of writing small code is to define a lot, not a LOT.
How to Remove Document Management Hurdles with X-Docs?
Art of Writing Small Code by Sumit misra
1. Art of Writing Small Code
Sumit Misra
General Manager
RS Software (India) Limited
2. Code is developed to address a Problem Space
Problem Space
Learning by knowledge sharing
3. Code maps the Problem Plane to a Solution Plane
Higher the Solution Plane in abstraction – smaller would the
code be
Code
Solution Plane
Problem Plane
Learning by knowledge sharing
4. MASHUP CODE Abstraction
LARGE GRAIN CODE
ASSEMBLY CODE
SCRIPTS
<< GRAIN >>
ASSEMBLY CODE
SMALL GRAIN Problem Plane
Learning by knowledge sharing
5. Partitioning the Problem
1 2
space such that the
solution planes are
consistent
IS
3 4 The prelude to the
Problem Space
Learning by knowledge sharing
6. Large Code Base Small Code Base
Problem Plane
1 2 3 4 1 2 3 4
Learning by knowledge sharing
7. World's smallest TETRIS program - one line
of BBC BASIC, 256 bytes in all written by
Olly Betts
0MODE9:OFF:GCOL-9:CLG:REPEATs=s+VPOS:PRINTCHR$30s:REPEATSYS6,135TOi,p,d:PRINTTAB
(p=0)CHR$9;:IFPOS=22VDU3100;VPOS,21;6667;:UNTIL0ELSEUNTILVPOS=25:v=ABSRNDMOD7:VD
U31:COLOUR3:REPEATm=9-INKEY(INKEYTRUEOR6)MOD3:FORr=TRUETO1:t=rANDSGNt:IFt=rCOLOU
Rv-15:VDUrEORm:i+=m=7AND9-6*r:IF0ELSEFORn=0TO11:d=nDIV3OR2EORd:VDUd:IF1<<(n+i)MO
D12AND&C2590ECDIV8^vAND975t+=POINT(p*POS,31-VPOS<<5):IFrVDUp,8:IF0ELSENEXT,:VDU2
0:UNTILt*LOGm:UNTILVPOS=3:Z
Is this the type of small code we want to write ?
Learning by knowledge sharing
8. High
Meta Language (Haxe/Neko)
Web Programming Language (Dart – Google)
Distributed / Meta Program / Reflection
Abstraction
Internet / RAD
Internet / Web
Object Oriented
Structured Programs
Low
1950 1960 1970 1980 1990 2000 2010 >>
Learning by knowledge sharing
9. Problem Plane is Expanding
Web Services
Solution Plane
Internet
Web Services
Web Services
Learning by knowledge sharing
10. Mobile Service
LOCATION
Web Services
EMAIL
Smart
Internet / Mobile User Experience
Web /
Cloud
APPLICATION GPS CODE
Gyro-meter (HTML5)
Magnetometer
SOC IAL
Pyrometer
NETWORK Light Sensor
Face Detector
Fingerprint Det
… more …
Learning by knowledge sharing
12. Stop Watch program
20 lines HTML/Java Script
25 lines
User Experience
Windows 7 Phone
43 lines Java / AWT
120 lines Windows / C++
Learning by knowledge sharing
13. SMALL CODE would need
BETTER DESIGN and
GOOD KNOWLEDGE of the
available frameworks and
services
“ I'm sorry for the long letter, my dear, but I did not have
time to make it short. “ – Winston Churchill
Learning by knowledge sharing
14. Thank you
sumit@rssoftware.co.in
Learning by knowledge sharing