<bijan.parsia, christos.kotselidis@manchester.ac.uk>
(bug reports welcome!)
One way of thinking of a class is as an abstract data type plus inheritance and polymorphism. — McConnell, 6.1
(There are other ways of thinking about a class!)
A Reason to Create a Class is a problem that creation solves
You can always ask: What problem? & Is it (well) solved?
Synthesised by Bob Martin:
SRP | The Single Responsibility Principle | A class should have one, and only one, reason to change. |
OCP | The Open Closed Principle | You should be able to extend a classes behavior, without modifying it. |
LSP | The Liskov Substitution Principle | Derived classes must be substitutable for their base classes. |
Synthesised by Bob Martin:
ISP | The Interface Segregation Principle | Make fine grained interfaces that are client specific. |
DIP | The Dependency Inversion Principle | Depend on abstractions, not on concretions. |
Principle | Creator/Coiner | |
---|---|---|
SRP, ISP,DIP | Bob Martin | |
OCP | Bertrand Meyer | |
LSP | Barbara Liskov |
A lot more is written about inheritance than about containment, but that's because inheritance is more tricky and error-prone, not because it's better. Containment is the work-horse technique in object-oriented programming.
Person
has-a name
Name
class manageThe world exhibits fractal complexity
Person
requires Name
One way of thinking about a routine is as an operation for an abstract data type.
Another way of thinking about a routine is as a (typically) named, invocable, block of code with a designated functionality (or purpose).
The most important reason for creating a routine is to improve the intellectual manageability of a program
—McConnell, 7, Key points
..cohesion is ...the workhorse design heuristic at the individual-routine level.
For routines, cohesion refers to how closely the operations in a routine are related. —McConnell, 7.2.
A class is a collection of data and routines that share a cohesive, well-defined responsibility. A class might also be a collection of routines that provides a cohesive set of services even if no common data is involved. —McConnell, 6
We can perform similar cohesion analysis over a class
The problem we're trying to solve is not lack of code
Experience goes a long way
Following slides derived from Making Software, Chapter 10
Note: statistically general conclusions may not apply in your case!
Note, changing requirements can kill getting it right
"...the greater the project's size, criticality, and stability, the greater the need for validated architecture feasibility evidence.
"very very small low-criticality projects with high volatility, the architecting efforts make little difference"
Note: There are other cost drivers; check the assumptions!
Chapter 26. Novice Professionals: Recent Graduates in a First Software Engineering Job
Chapter 26. Novice Professionals: Recent Graduates in a First Software Engineering Job
"An overarching theme of new developers’ communication problems is knowing how and when to ask questions of others.
"In general, novices do not ask questions soon enough, and often struggle to ask questions at an appropriate level."
Chapter 26. Novice Professionals: Recent Graduates in a First Software Engineering Job
Software problems can easily become global problems
Fourth time for me!
Second time for Christos!!
We hope you've learned stuff
We have!