diff --git a/assignments/Fundamentals-Practice.pdf b/assignments/Fundamentals-Practice.pdf deleted file mode 100644 index de5a81c..0000000 Binary files a/assignments/Fundamentals-Practice.pdf and /dev/null differ diff --git a/assignments/PA1-CSVReader.pdf b/assignments/PA1-CSVReader.pdf deleted file mode 100644 index 30f9a28..0000000 Binary files a/assignments/PA1-CSVReader.pdf and /dev/null differ diff --git a/assignments/PA3-UnitConverter.pdf b/assignments/PA3-UnitConverter.pdf deleted file mode 100644 index b97c28e..0000000 Binary files a/assignments/PA3-UnitConverter.pdf and /dev/null differ diff --git a/assignments/PA4-Final-Project.pdf b/assignments/PA4-Final-Project.pdf deleted file mode 100644 index 7a68c48..0000000 Binary files a/assignments/PA4-Final-Project.pdf and /dev/null differ diff --git a/assignments/PA4-Readability.doc b/assignments/PA4-Readability.doc index 16dfde2..b47a322 100644 Binary files a/assignments/PA4-Readability.doc and b/assignments/PA4-Readability.doc differ diff --git a/assignments/PA4-Readability.pdf b/assignments/PA4-Readability.pdf deleted file mode 100644 index 0ceefe4..0000000 Binary files a/assignments/PA4-Readability.pdf and /dev/null differ diff --git a/assignments/PA4-Threaded-Downloader.pdf b/assignments/PA4-Threaded-Downloader.pdf deleted file mode 100644 index 4ee5295..0000000 Binary files a/assignments/PA4-Threaded-Downloader.pdf and /dev/null differ diff --git a/assignments/PA4-Typing-Game.pdf b/assignments/PA4-Typing-Game.pdf deleted file mode 100644 index 466cf36..0000000 Binary files a/assignments/PA4-Typing-Game.pdf and /dev/null differ diff --git a/assignments/Week10-assignments.pdf b/assignments/Week10-assignments.pdf deleted file mode 100644 index 13d9548..0000000 Binary files a/assignments/Week10-assignments.pdf and /dev/null differ diff --git a/images/VS2-Search-Extensions.png b/images/VS2-Search-Extensions.png deleted file mode 100644 index a84c5a2..0000000 Binary files a/images/VS2-Search-Extensions.png and /dev/null differ diff --git a/images/VS1-Extensions-List.png b/images/VSCode-Java-Extensions.png similarity index 100% rename from images/VS1-Extensions-List.png rename to images/VSCode-Java-Extensions.png diff --git a/patterns/Command-Pattern.doc b/patterns/Command-Pattern.doc deleted file mode 100644 index 40adff1..0000000 Binary files a/patterns/Command-Pattern.doc and /dev/null differ diff --git a/patterns/Composite-Pattern.ppt b/patterns/Composite-Pattern.ppt deleted file mode 100644 index d2c93b7..0000000 Binary files a/patterns/Composite-Pattern.ppt and /dev/null differ diff --git a/patterns/Factory-Methods.doc b/patterns/Factory-Methods.doc deleted file mode 100644 index c42b941..0000000 Binary files a/patterns/Factory-Methods.doc and /dev/null differ diff --git a/patterns/Intro-Design-Patterns.pdf b/patterns/Intro-Design-Patterns.pdf index 1529571..2e28d0e 100644 Binary files a/patterns/Intro-Design-Patterns.pdf and b/patterns/Intro-Design-Patterns.pdf differ diff --git a/patterns/Iterator-in-Python.pptx b/patterns/Iterator-in-Python.pptx index 1c31ed8..3ead1a9 100644 Binary files a/patterns/Iterator-in-Python.pptx and b/patterns/Iterator-in-Python.pptx differ diff --git a/patterns/Iterator-uml.uxf b/patterns/Iterator-uml.uxf index 4de4be2..f890477 100644 --- a/patterns/Iterator-uml.uxf +++ b/patterns/Iterator-uml.uxf @@ -1,13 +1,13 @@ - 10 + 12 UMLClass - 210 - 180 - 190 - 90 + 24 + 24 + 228 + 108 <<interface>> Iterator<T> @@ -19,10 +19,10 @@ next(): T UMLClass - 210 - 310 - 190 - 70 + 24 + 180 + 228 + 84 ConcreteIterator -- @@ -33,10 +33,10 @@ next(): T Relation - 300 - 260 - 30 - 70 + 132 + 120 + 36 + 84 lt=<<. 10.0;10.0;10.0;50.0 @@ -44,10 +44,10 @@ next(): T Text - 420 - 180 - 100 - 70 + 276 + 24 + 120 + 84 T is a type parameter style=wordwrap @@ -56,10 +56,10 @@ style=wordwrap UMLClass - 530 - 180 - 190 - 90 + 408 + 24 + 228 + 108 <<interface>> Iterator[T] @@ -70,10 +70,10 @@ __next__(): T Relation - 620 - 260 - 30 - 70 + 516 + 120 + 36 + 84 lt=<<. 10.0;10.0;10.0;50.0 @@ -81,10 +81,10 @@ __next__(): T UMLClass - 530 - 310 - 190 - 70 + 408 + 180 + 228 + 84 ConcreteIterator -- diff --git a/patterns/MVC-Pattern.ppt b/patterns/MVC-Pattern.ppt index 331cb49..2bf568f 100644 Binary files a/patterns/MVC-Pattern.ppt and b/patterns/MVC-Pattern.ppt differ diff --git a/patterns/Observer-Pattern.ppt b/patterns/Observer-Pattern.ppt deleted file mode 100644 index 9d02af0..0000000 Binary files a/patterns/Observer-Pattern.ppt and /dev/null differ diff --git a/patterns/Patterns-Review-2.doc b/patterns/Patterns-Review-2.doc index 5649c22..4fab9b3 100644 Binary files a/patterns/Patterns-Review-2.doc and b/patterns/Patterns-Review-2.doc differ diff --git a/patterns/Singleton-Pattern.ppt b/patterns/Singleton-Pattern.ppt index c4b5219..7051d94 100644 Binary files a/patterns/Singleton-Pattern.ppt and b/patterns/Singleton-Pattern.ppt differ diff --git a/images/observer-example-1.jpg b/patterns/diagrams/observer-example-1.jpg similarity index 100% rename from images/observer-example-1.jpg rename to patterns/diagrams/observer-example-1.jpg diff --git a/images/strategy-pattern-wo-params.png b/patterns/diagrams/strategy-pattern-wo-params.png similarity index 100% rename from images/strategy-pattern-wo-params.png rename to patterns/diagrams/strategy-pattern-wo-params.png diff --git a/images/strategy-pattern.png b/patterns/diagrams/strategy-pattern.png similarity index 100% rename from images/strategy-pattern.png rename to patterns/diagrams/strategy-pattern.png diff --git a/patterns/index.md b/patterns/index.md index f2bc58c..3b33019 100644 --- a/patterns/index.md +++ b/patterns/index.md @@ -2,68 +2,85 @@ title: Design Patterns --- -*Design Patterns* are reusable designs for common situations. +Presentation: [Intro to Design Patterns](Intro-Design-Patterns.pdf) + +*Design Patterns* are reusable designs for common, recurring situations. Each design pattern consists of: * **Context** - a situation where a design solution is needed * **Forces** (or Motivation) - motivation or "needs" of the situation * **Solution** - a design that solves the problem -* **Applicability** - when the pattern applies. There may be many solutions to a particular context; the applicability can help. +* **Applicability** - when the pattern applies. The "applicability" can help you choose between multiple possible solutions and avoid misusing a pattern. * **Consequences** - good and back effects of this solution -* **Example** - at least one example of using the pattern - -Presentation: [Intro to Design Patterns](Intro-Design-Patterns.pdf) +* **Example** - an example of using the pattern ### Principles & Goals Motivate Patterns Design Patterns are motivated by design **Goals** and **Principles**. -Software is plagued by these problems: + +The Need: Software is plagued by these problems * change - requirements change, technology changes, the environment where software is used changes * bugs (errors) * complexity -* difficulty to maintain or evolve over time +* difficult to maintain and evolve over time These forces have given rise to **principles** for good design and coding. ## Principles and Goals for Software Design -Some principles for good design have emerged -from experience solving the common problems with software, +These "principles" for good design have emerged +from experience solving common problems with software, through repeated application. -The design principles are what motivate the design patterns. +These principles are what motivate the design patterns. -This is only a brief summary and not a complete list. +This is only a brief summary. Please read the references to learn in more depth. * **Single Responsibility** - a class should have one responsibility. Robert Martin explains this as *a class has only one reason to change*, e.g. one driver or boss that decides what it should do. + * **Open-Closed Principle** - you can extend the functionality of a class without modifying the class itself + * **Liskov Substtitution Principle** - in an application, you should be able to use a subclass object anywhere it's superclass is expected and the application will behave as expected. Subclasses should pass the "*is a*" test. + * **Don't Repeat Yourself** - avoid duplicate logic and duplicate code (applies to design *and* coding) + * **Prefer delegation over inheritance**. It is more flexible to design objects so that A delegates behavior to B, and set B as an attribute of A, rather than make B a subclass of A that specializes some behavior. The Adapter, State, and Strategy patterns all use delegation. + * **Code to a specification, not an implementation**. Write code based on the specification (or public interface) for how an object or method *should* behave rather than details of how it's implemented. In Java, depend on the *List* API rather than *ArrayList* (an implementation). * **Depend on abstractions, not on concretions**. Similar to the previous principle, but at a higher (more abstract) level. + * **Don't Reinvent the Wheel**. Don't write code for something that the language already provides, or something that can be provided by an existing, well-tested and maintained package. For example, don't write your own CSV file parser or password encrypter. There are lots of these and they contain fewer (if any) flaws that what you would write yourself. + * **Separate what Varies from what Stays the Same, and Encapsulate the part that Varies**. "What" means "a part of the code or some behavior of the code". + * **Information Expert** - put a method in the class that has most of the information needed to perform the method. + * **Separation of Concerns** - classes and components (groups of classes) should each be concerned with a single aspect of the program. A Data Access Object is concerned with saving and retrieving objects to/from a database, but doesn't manipulate the objects itself. Separating object creation from object use is often helpful -- e.g. use a Factory for objects. + * **Dependency Injection** - If an object depends on some other object, try to *inject* that dependency from other code, esp if the dependent part may change. This helps with *Separation of Concerns*, *Separate what changes from what stays the same*, and reduces coupling. - Example: in Coin Purse we *inject* a WithdrawStrategy using a `set` method. -* **Low Coupling**, esp. coupling to unstable or unrelated things. Coupling to the Java API (for Java apps) isn't a problem because the Java API is quite stable. + +* **Strive for Loosely Coupled Objects** (Low Coupling), especially. coupling to unstable or unrelated things. Coupling to essential, stable APIs (the Java or Python API, the JDBC API) isn't a problem because these are quite stable and well maintained. + * **Command-Query Separation** - queries should not change the state of an object + * **Simplicity** - complexity is the enemy of correctness and security. Strive for simple designs. -Some **goals** for class design (the 5 "C"s of class interface design): -* High Cohension -* Consistency - be consistent in naming of methods, variables, and classes. Be consistent in their behavior, too. -* Completeness - a class should provide enough methods for it's intended use. -* Convenience - try to provide an API that's *convenient* for the programmer, but don't create lots of redundant methods. -* Clarity - a method or class's name and interface should clearly suggest it's purpose +## Goals for Class Design + +Some **goals** for class design (the 5 "C"s of class interface design) + +- High Cohension +- Consistency - be consistent in naming of methods, variables, and classes. Be consistent in their behavior, too. +- Completeness - a class should provide enough methods for it's intended use. +- Convenience - try to provide an API that's *convenient* for the programmer, but don't create lots of redundant methods. +- Clarity - a method or class's name and interface should clearly suggest it's purpose ## Specific Design Patterns @@ -90,14 +107,12 @@ The links are presentation slides. ## Learn More -Online: +* [Refactoring Guru](https://refactoring.guru/design-patterns) has a [catalog of patterns](https://refactoring.guru/design-patterns/catalog) with very visual examples and pseudocode, * [Python Patterns Guide](https://python-patterns.guide/) explains how and "why" to apply patterns in Python. Some good insight but I think you need to know a particular pattern before reading his explanation. * [Wikipedia](https://en.wikipedia.org/wiki/Software_design_pattern) has a list of patterns with a page describing each one, -* [Refactoring Guru](https://refactoring.guru/design-patterns) has a [catalog of patterns](https://refactoring.guru/design-patterns/catalog) with very visual examples and pseudocode, - * [Geekforgeeks](https://www.geeksforgeeks.org/software-design-patterns/) has good descriptions with UML and Java examples. * [Game Programming Patterns](https://gameprogrammingpatterns.com/contents.html) application of patterns to games. Examples use C++. diff --git a/projects2017.md b/projects2017.md deleted file mode 100644 index 1c33458..0000000 --- a/projects2017.md +++ /dev/null @@ -1,34 +0,0 @@ -# OOP 2017 Projects - -| Project Name | Members | Web Page | -|-----------------------|----------|-----------| -| [Typing Thrower](https://github.com/winChawakorn/TypingThrower) | Chawakorn, Vittunyuta | [https://winchawakorn.github.io/TypingThrower/](https://winchawakorn.github.io/TypingThrower) | -| [Bookshelf](https://github.com/zepalz/Book-Shelf) | Archawin, Triwith | [https://zepalz.github.io/Book-Shelf/](https://zepalz.github.io/Book-Shelf/) | -| [Chat Application](https://github.com/Gotsira/chatapplication) | Sirasath, Issaree | [https://gotsira.github.io/chatapplication/](https://gotsira.github.io/chatapplication/) | -| [Course Feedback](https://github.com/guitarpawat/course-feedback) | Pawat, Noppawan | Excellent technology description in [Project README.md](https://github.com/guitarpawat/course-feedback/blob/master/README.md) | -| [Health Me](https://github.com/nottpty/healthme) | Patinya, Narut | Documentation in README.md | -| [Menu](https://github.com/csupisara/MenuProject) | Supisara, Sathira | [https://csupisara.github.io/MenuProject/](https://csupisara.github.io/MenuProject/) | -| [Movie Ticket](https://github.com/hereton/MovieTicket) | Wongsathorn, Totsapon | Documentation in README.md | -| [Remec](https://github.com/thitgorn/Remec) | Kongpon, Thitiwat | [https://thitgorn.github.io/remec/](https://thitgorn.github.io/remec/) | -| [Simple Text-to-Speech](https://github.com/printto/Simple-Text-to-Speech) | Pappin | Good documentation in README.md | -| [SKE Blog](https://github.com/lunaticSKE12/SKE-Blog) | Napong | Documentation in README.md | -| [Surasak Cow Farm](https://github.com/yotharit/OOP2-PA6-Surasak-Cow-Farm) | Tharit | [https://yotharit.github.io/OOP2-PA6-Surasak-Cow-Farm/](https://yotharit.github.io/OOP2-PA6-Surasak-Cow-Farm/) | -| [Taxi Fare Estimator](https://github.com/napnie/TaxiFareEstimateCalculator) | Nitith | [https://napnie.github.io/TaxiFareEstimateCalculator/](https://napnie.github.io/TaxiFareEstimateCalculator/) | -| [Terrarium](https://github.com/JirayuL/Terrarium) | Jirayu, Wanchanapon | [https://jirayul.github.io/Terrarium/](https://jirayul.github.io/Terrarium/) | -| [Visual Piano](https://github.com/Non9441/visual-piano) | Non, Varit | Documentation in README.md | - - -### Project Documentation - -Every project should have documentation. - -* README.md - first thing people see when they visit your Github project. It should contain: - * Describe what the project does - * Introduce interesting technology used - * Names of author(s) - * How to install and run project, or link to installation instructions - * Links to other libraries you use, and references you mention - * Link to your Github pages site (or other web home) if you have one -* Installation instructions - either in README.md, or another file with a *link* in README.md -* Source code should be commented, and written as best you can. -* (Optional) Github pages site for the project diff --git a/uml/UML Sequence Diagram Practice.doc b/uml/UML Sequence Diagram Practice.doc index 7b7c128..a4d36dc 100644 Binary files a/uml/UML Sequence Diagram Practice.doc and b/uml/UML Sequence Diagram Practice.doc differ diff --git a/uml/UML-Class-Diagram.ppt b/uml/UML-Class-Diagram.ppt index 6cb5584..81313e7 100644 Binary files a/uml/UML-Class-Diagram.ppt and b/uml/UML-Class-Diagram.ppt differ diff --git a/uml/UML-Sequence-and-Interaction.ppt b/uml/UML-Sequence-and-Interaction.ppt index 5976415..8dbd6d3 100644 Binary files a/uml/UML-Sequence-and-Interaction.ppt and b/uml/UML-Sequence-and-Interaction.ppt differ diff --git a/uml/UML_practice.md b/uml/UML-practice-java.md similarity index 100% rename from uml/UML_practice.md rename to uml/UML-practice-java.md diff --git a/unittesting/UnitTesting.ppt b/unittesting/JavaUnitTesting.ppt similarity index 100% rename from unittesting/UnitTesting.ppt rename to unittesting/JavaUnitTesting.ppt diff --git a/unittesting/PythonUnitTesting.pdf b/unittesting/PythonUnitTesting.pdf deleted file mode 100644 index 27d7a58..0000000 Binary files a/unittesting/PythonUnitTesting.pdf and /dev/null differ diff --git a/unittesting/PythonUnitTesting.ppt b/unittesting/PythonUnitTesting.ppt deleted file mode 100644 index 2ccc995..0000000 Binary files a/unittesting/PythonUnitTesting.ppt and /dev/null differ diff --git a/unittesting/UnitTesting.pdf b/unittesting/UnitTesting.pdf deleted file mode 100644 index 6bc72e9..0000000 Binary files a/unittesting/UnitTesting.pdf and /dev/null differ