+ getDate() + getPosition() + publish(…) User + login() + getImages() + getFriends() SocialNetworkConnection + authenticate(User) + publish(Image) Filter + apply() SepiaFilter + apply() etc. CropFilter + apply() Camera + acquire() Position + getLatLon() + getDistance() Map + addPosition(Position) + display() friend Disclaimer: this class diagram is mostly wrong because of missing attributes, missing cardinalities, lack of clarification between aggregations and compositions, missing filters, missing specialisations for various social networks, etc. 2
a mental model of the actual or imagined objects it represents, and of their interactions. ▶ Albeit a valid paradigm, it reaches limits as your project grows. ▶ Component-based design recommends to build complex systems by assembling largely cohesive loosely coupled components. ▶ Design components the way you like. Nothing matters but the interface. 5
You can explain what it does in few seconds/few words. If it can do many things, it is most likely not a component! A component shall yield a significant output from a minimal input. A component shall address specific needs without any adaptation. 7
unexpected ways. A component shall handle erroneous inputs, unexpected behaviour. A component shall be rigorous about versions and dependencies. Comprehensive testing 1 and benchmarking are considered good practice. 1 Understand unit testing, integration testing, input validity testing 8
on. Hide your hard work and smart optimisations to the end user. You should be able to redesign/replace each component at a minimal cost. Don’t get misguided by the premature optimisation issue ✓ Be aware of what things cost. Complicated design often ends up missing the point. 9
does not matter: ▶ the programming paradigm; ▶ the programming language; ▶ the elements of design; ▶ the pace of deliveries; ▶ the guy for the job; and may change your mind at any time. Interfaces do matter Start writing a readme, and a test case describing how people will make use of your component. 11
will first look at how to call it. Avoid exposing your data model outside your component. Choose generic types, generic return codes, generic exceptions. Stop writing classes! 2 2 Check this talk [here] 13
filtering lines matching a pattern. ✓ Parses files or stdin, writes on stdout, Supports regular expressions ✓ grep does not need to read the whole input, without you needing to know it! 3 3 Check this video [here] 15
arrays to Python. ✓ Totally transparent, you don’t need to know C. ✓ You can transform Python arrays to numpy arrays, and access numpy arrays as if they were Python arrays. 16
provide a service, not extra pain! Questions to ask before delivering: 1. Is it simple to install? (or access for a web app) 2. Is it simple to use? 18
component behaves before installing it. There are lots of fun ways to write documentation ▶ Write a readme; ▶ Write a blog post; ▶ Prepare an iPython notebook 4; Do you know how to write man/help files? Do you know how to feed the Help menu of your application? 4 Also available for other languages, check [here] 19
5 Decent people do care, and you should care too. No license is not an option. “Do whatever you want” is an option. Just say it! Check the MIT license if you want it simple and permissive. 5 Have a look at http://www.choosealicense.com 20
want to hear about it. Provide compiled versions for most architectures. If compilation must be performed on the user side, make it painless. Adopt a no questions asked policy But provide explicit error messages if things fail. 21
store your components. Have a tool to install them and take care of your dependencies. Commonly used package management systems ▶ Python: pip (virtualenv helps), also conda; ▶ OCaml: opam / findlib; ▶ Ruby: gem / bundler; ▶ LaTeX: ctan; also Firefox add-ons, Linux repositories, etc. 22
reference for remarkable design. All command line tools are remarkable examples of components, abiding by the Unix philosophy: 6 ▶ Write programs that do one thing and do it well; ▶ Write programs to work together; ▶ Write programs to handle text streams, because that is a universal interface. 6 Check this article [here] 24
7 Respect intellectual property of others. Don’t publish others’ work without their permission. If you are concerned about money, publishing a compatible open version with degraded performance can be a strategy. 7 You may want to consider https://github.com/ 25
your interfaces and documentation. ▶ You get a reason to push yourself and show off your best. Hide your complex work, show how simple it really is. ▶ You harvest the benefits of your discipline for your own projects. ✓ You may even expect feedback. 26
of great software does not abide by your bottom lines, and it should not affect your mental health. ▶ Write code every day Practice makes better, which is already a lot! ▶ Write every day It’s all about human language in the end. 8 Read “Don’t be an ass” 28