theory Flashcards
(81 cards)
The word design is
both a verb (the process of designing) and a noun (outcome of the process) (this creates ambiguity around the word design)
Textbook definition of design:
the construction of abstractions of data and computation and the organization of these abstractions into a working software application.
Design Space:
an n-dimensional geometric space where each dimension corresponds to a design quality attribute (understandability, reusability, ease of implementation)
Space of possible solutions
Space of acceptable solutions
what kind of process is design?
highly heuristic process (iterative problem solving, guided by principles and design techniques)
Ignorant surgery:
the problem of modifying code in a way that does not respect the original structure
Design context:
a specific set of requirements and constraints within a domain in which a design solution must be formed and integrated.
Sustainability:
the idea of having design decisions be self-evident in code
Process model:
describes how the different steps required to create a system are organized.
Waterfall software processing model
very planning heavy
Agile development:
more organic approach
Sustainability:
the idea of having design decisions be self-evident in code
practice:
well understood way of doing something to achieve a certain benefit
Ex) version control (keep track of changes to software development artifacts)
Ex) pair programming
Refactoring:
improving the design without changing the functionality
Technical debt
when programmers implement quick and dirty solutions that don’t align properly with the existing design
When decomposing a system into distinct, manageable abstractions,
the abstractions have to be isolated from teacher (not dependent on each other).
Encapsulation:
enclose something as if it were in a capsule
Ex) a nut is encapsulated in its shell and the shell serves to protect the nut. The shell is synonymous with an interface. Encapsulation makes it easier to understand code in isolation and it’s easier to change one part of the code without breaking anything.
Ex)deck of cards where there are 52 cards and each card can be represented by its suit and rank
Object state:
built in characteristics or properties of an object.
State diagram:
models the behavior of a single object, specifying the sequence of events that an object goes through during its lifetime in response to events
NULL OBJECT pattern:
encapsulate the absence of an object by providing a substitutable alternative
Consider declaring instance variables final whenever possible;
singleton pattern
Consider using the SINGLETON pattern for classes that should yield only one instance of a stateful object, while providing a global access point to this instance.
ex) A country can have only one official government.
Remember that additional data can be attached to instances of inner classes, ei-ther in the form of a reference to an instance of an outer class, or as copies of local variables bundled in a closure.
FLYWEIGHT pattern:
If objects are not designed to be unique, override the equals and hashCode
methods; if objects should be unique, consider using the FLYWEIGHT pattern to
enforce uniqueness
FLYWEIGHT pattern: lets you fit more objects into the available amount of RAM by sharing common parts of state between multiple objects instead of keeping all of the data in each object. Flyweight objects are immutable. This means that they cannot be modified once they have been constructed. We use a HashMap that stores reference to the object which have already been created, every object is associated with a key.
In browsers, we can use an image in multiple places in a webpage. Browsers will load the image only one time, and for other times browsers will reuse the image from cache.
composite pattern
If a design problem requires structures that change at run-time or can be combined, consider building the structures by combining objects, as opposed to defining new classes for each possible structure.
Use the C O M P O S I T E when you need to manipulate collections of objects the same way as single (“leaf”) objects. It lets you compose objects into tree structures and then work with these structures as if they were individual objects.
ex) Armies of most countries are structured as hierarchies.
decorator pattern
Use the DECORATOR when you need to add functionality to certain objects, while being able to use them in place of “regular” objects. It lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors.
The COMPOSITE and DECORATOR can be combined easily, especially if they share the same component type.
respect the Law of Demeter:
a module should not know about the inner details of the objects it manipulates