Software Development Principle: Tell, don’t ask
By Willo van der Merwe | Technical Competency Lead
A key consideration when building or enhancing custom software is the total cost of maintenance and enhancement over time. As business focus shifts, new products are taken to market and customer engagement changes. There are some simple approaches and principles to software development, which, if implemented correctly, can exponentially reduce the cost of future change.
These principles and patterns are what help create well-structured and maintainable code. One such principle is “Tell, don’t ask”. It suggests that instead of asking an object about its internal information and making decisions externally, we should directly tell the object what we want it to do. This promotes a clear separation of responsibilities and helps make code easier to understand and modify.
Other important software development principles
Another important concept is Dependency Injection (DI) and Inversion of Control (IoC).
DI is a technique that focuses on providing dependencies to an object from an external source, while IoC is a broader architectural concept that involves delegating the creation and management of objects to a higher-level framework or container. These principles help decouple components, promote modularity, and enable easier testing and maintenance of software systems.
The benefits of bringing these principles together
By combining the “Tell, don’t ask” principle with DI and IoC, developers can design software that is more flexible, modular and easier to maintain.
These concepts also:
- promote encapsulation,
- reduce dependencies on internal state,
- and allow for better separation of concerns.
Ultimately, they contribute to the creation of software systems that are more robust, adaptable, and understandable, even for non-technical individuals.
and ???????????? bonus ????????????:
From the Bookshelf ????
“The Pragmatic Programmer: From Journeyman to Master” is a highly regarded book by Andrew Hunt and David Thomas that provides practical advice and valuable insights for developers looking to improve their skills.
Covering a wide range of topics, including code organisation, debugging, testing, automation and documentation, the book serves as a comprehensive guide for software developers striving to excel in their craft.
It promotes a pragmatic approach, encouraging programmers to focus on practical solutions that work in real-world scenarios. By emphasising critical thinking, problem-solving, and continuous learning, the authors empower developers to become more effective and efficient in their work.
A distinguishing feature of the book is its emphasis on collaboration and communication within a development team. It highlights the importance of clear documentation, maintaining code quality, and upholding professional ethics. By addressing not only the technical aspects but also the broader context of software development, such as project requirements and business goals, the book equips developers with a holistic perspective that leads to delivering software that meets both functional and practical needs.
“The Pragmatic Programmer” is an invaluable resource for developers at any stage of their career.
Final thoughts
Ultimately, a tried and tested software development principle – such as “tell, don’t sell” or DI or IoC – contributes to the creation of software systems that are more robust, adaptable, and understandable. Often, systems with these characteristics are also easier to maintain and enhance.
All of this works in your favour; it leads to a quicker, more cost-effective delivery of the technology that enables your differentiation in the marketplace.