Skip to main content

Posts

Showing posts with the label best practices
Of Hollywood, frameworks, APIs and inversion of control I recently chanced to learn about a pattern called the 'Inversion of Control'. This is primarily used to abstract out the creational part of dependent components from a class is question. In simple terms, a class need not create dependent objects. This independence of the creational logic allows such classes to be more loosely coupled to dependent objects, thus resulting in easy replacement of the dependent objects during run-time. This technique is used by unit-tests to isolate a particular class from its dependencies so that the class / object in question can be tested alone. We usually resort to using creational patterns like the singleton or the factories to decouple the creator from the logic of creation. What we essentially do is, we just add one more level of indirection to the actual creation logic. Earlier, we used to manually use new to create an object. With the singleton, our class uses the singleton, which in...
Beyond STL The Standard Template Library has made its way into the standards, being shipped as an indispensable object oriented core low-level library. Known to most C++ developers fondly as the STL, it provides standard object oriented reusable components that allow developers to focus on the problem in hand rather than think in terms of storing, retrieving and sorting data-structures. The most common classes that you might have encountered would be the string, the vector and the list. There is more than just these in STL and plenty of books and articles have been devoted to the innards of STL and how to use them effectively. STL liberates the developers from constructing custom linked lists and hash tables by using templates thereby aiding them in focusing at more higher level goals of the software. My aim in the article is to focus at the next level of software development. Though not focused at topics like architecture and design patterns, we will be looking at a public domain C++ ...
Architectural Patterns and kernels Monolithic architecture - Exposes a high level interface where with core services closely coupled with each other. Linux and other monolithic kernels provide a high level system call API and internally, services like memory management, I/O etc are tightly coupled. Pro: Performance Con: Defect on one service may affect other services Microkernel architecture - Services decoupled and run on own process. Use message passing mechanism to communicate with each other to reduce coupling. Pro: Easy to extend or add new features. Malfunctioning service can be restarted without affecting others Con: Slower Hybrid kernels - Micro kernels that have non-essential code in kernel space for efficiency. Microsoft Windows NT and strains are an example Exokernels - Provides a library for core OS features (in terms of the developer requesting particular pages of memory or blocks of diskspace). Application developer builds on top. Multiple li...
Some Behavioral Patterns Visitor: Abstracts operations on a data structure and to avoid making changes to existing data structures. Allows new operations to be added without changing data structures Strategy: Abstracts similar algorithms so that it can be interchanged without affecting the data structure. Used to eliminate switch-case statements Iterator: Provides a unified mechanism to traverse data structures without encapsulating the traversal logic