diff --git a/lectures/revealjs/11-lecture-solid-uml.adoc b/lectures/revealjs/11-solid-uml.adoc similarity index 78% rename from lectures/revealjs/11-lecture-solid-uml.adoc rename to lectures/revealjs/11-solid-uml.adoc index 06ab669ba0ec089d62b31b2682e078ba37d47615..16f43311d4656959eee4091ce89b96e56e929fad 100644 --- a/lectures/revealjs/11-lecture-solid-uml.adoc +++ b/lectures/revealjs/11-solid-uml.adoc @@ -8,8 +8,7 @@ include::{includedir}header.adoc[] [.smaller-80][.center-paragraph] -IT1901 Fall 2022 - {LECTURE_NO} - +IT1901 Fall 2023 - {LECTURE_NO} [.smaller-30] @@ -17,8 +16,11 @@ Partially based on slides from Torgeir Dingsøyr and Hallvard Trætteberg == Overview + - OOD - SOLID, DRY +- Some useful considerations - UML Diagrams +- Summary [background-color = "#124990"] [color = "#fff6d5"] @@ -37,12 +39,41 @@ designing object classes and the relationships between these classes.†== Object Oriented Principles -- Encapsulation - Abstraction +- Encapsulation - Inheritance - Polymorphism +== Abstraction + +- hiding the internal data and implementation from the external world +- hide complexity and show essential information +- could be classified further +** data abstraction +** process abstraction +- abstract classes and interfaces + + +== Encapsulation + +- integrating fields (data) and methods (behaviors) into a single unit +- fields are hidden from other classes +- fields can only be accessed by the methods of the class in which they are found + + +== Inheritance + +- mechanism that allows classes to acquire fields and behaviors from other class +- the properties of the "parent" class are inherited by the "child" class + +== Polymorphism + +- the ability to perform a single action in different ways +- differently stated - have one interface but have multiple implementations +** overriding +** overloading + == Common issues OOD - External dependencies: @@ -161,10 +192,56 @@ https://en.wikipedia.org/wiki/Don%27t_repeat_yourself +[background-color = "#124990"] +[color = "#fff6d5"] +== Some useful considerations + + +== Refactoring + +- work on the code without adding functionality +- simplify and optimize +- make it more maintainable and reusable + +== Refactoring (2) + +- find problem areas and improve +** very long classes or methods +** long list of parameters +** confusing package structures +** ... + +== Refactoring (3) + +- aim for short methods with simple control flow +- avoid recursion (harder to understand the ) +- limit loops +- limit variables to the smallest scope possible + +== Nesting + +- complex flow in methods is hard to understand +- if you are beyond 2-3 levels you need to consider refactoring + +== Naming + +- use suggestive names +- adhere to conventions +- do not abbreviate +- avoid single letter variables (y) +- do not include types in names (intCount, bResult) + +== Naming (2) + +- do include units where needed ( delayInSeconds ) +- difficulty naming might indicate the need to rethink design +- avoid naming classes Abstract... or Base... +- avoid using an evergrowing "Utils" class + [background-color = "#124990"] [color = "#fff6d5"] -== UML +== UML Diagrams [.smaller-80] == UML - Unified Modelling Language @@ -281,6 +358,7 @@ TodoListListener -> TodoController: updateTodoListView ``` + [background-color = "#124990"] [color = "#fff6d5"] == Summary