Graduate Program KB

Chapter 11 - Systems

  • Systems should separate startup - when objects are constructed - from runtime logic
    • Lazy evaluation - Not creating an object or evaluating an expression until we need it, is NOT separation
      • Ensures null is never returned and can mean faster startup times
      • Results in less modulation if used too many times.
  • One way to separate the two is move the modules called by main to outside files, and only ensure the main function builds the necessary objects and passes them to the rest of the application.
    • This would move all dependencies away from main.
  • "Implement today's stories, then refactor and expand the system to implement new stories tomorrow." This iteration and incrementation process can be seen in test driven development and code refactoring, as well as all agile development methodologies.
  • Aspect-oriented programming (AOP) is a way to maximise modularity across code.
  • It uses aspects to point out which parts of a system need to be modified to support a concern.
    • Java Proxies are used to wrap method calls in objects or classes, but only work in interfaces.
      • Proxies are complex and have a lot of code even for a simple use case.
    • Pure Java AOP Frameworks use proxies to implement aspects in Java. They allow you to write Plain Old Java Objects (POJOs).
      • POJOs have no dependencies, so it is easier to write and maintain code, as well as run tests.
    • AspectJ is an extension of Java that uses Java 5 to annotate aspects.
  • Using these approaches will decouple your code, making it easier to test and scale up your code to more be complex in the future.
  • Using modularity and separation of concerns make decision making and code management easier.
  • You should wait until the last possible moment to make decisions, this is to maximise the amount of information that informs those decisions.
  • Domain Specific Languages (DSLs) are scripting languages or APIs that are optimised for specific problems or domains.
    • DSLs raise the abstraction level so design patterns and idioms are not needed, and allow the developer to read and implement the code without issue.