Test your system ASAP § Read the Online Proctored Exam Guidelines to know what to do in case of a problem during the exam § Midterm Exam available March 11 only during lecture time from 4:30 pm to 5:45 pm. § No lecture that day. Go directly to your exam § It is a CLOSED BOOK exam. Do not use any material § Scratch paper is allowed. Empty White Paper. Show it on camera when you show your environment!
cases drive to Single Responsibility (SRP), dependency injection (DI), and interfaces. § Writing test cases minimize coupling because tight coupling makes it difficult to write tests. § Refactoring: increase cohesion, decrease coupling, separate concerns, modularize, shrink functions and classes, choose better names, and so on. § Having tests eliminates the fear that cleaning up the code will break it.
or methods) represents additional work, risk, and unnecessary complexity. § Use Inheritance à overloading § Common mistake: get our code working and then move on to the next problem. Take care of what you have created!
of the cost is in long-term maintenance. § It is critical to understand what the system does. § Select good names, keep items small, use patterns (observer, visitor, command, interpreter, mediator, decorator, adapter, singleton, factory, etc.). § Tests should also be expressive.
§ Do not end with a program that have too many tiny classes and methods. Keep classes and methods counts low. § Dogmatism vs Pragmatism. § This rule is lowest priority compared with the other principles and rules. But it is a rule. Do not ignore it.
etc. Is it Readable (guidelines, patterns, …)? Is it Understandable (short, expressiveness, …)? § Ask yourselves: Are the graders going to be able to understand this?
§ Delegate (behavior) § Factory (creation) § Singleton (centralize) § MVC (Model-View-Controller). No, it is not about having classes named, View, Controller, and Model
public void makeSomething(); } } public class B1 implements Behavior { public void makeSomething() { // ... } } public class B2 implements Behavior { public void makeSomething() { // ... } } public class User { private Behavior b; public void action() { b.makeSomething(); } public User(Behavior b) { this.b = b; } }
class has a dependency on another class, if it uses an instance of this class. § A class should not configure its dependencies statically (new) but should be configured from the outside (using vs having). § hard dependency – a class creates an instance of another class via the new operator § dependency injection – passing of a dependency to a dependent object (as a parameter)
{ ... public ClientFrame() { ... = new PlotPanel(); ... = new FacePanel(); ... = new ConsolePanel(); ... = new JButton(); ... = new JLabel(); } } public class ClientFrame { public ClientFrame(Jpanel a, Jpanel b) { } }
to the degree to which the different classes depend on each other. All classes should be independent as far as possible. § Create Mock objects (dummy implementations that emulate real code). § Create Interfaces