diff --git a/ChangeReqLab_merged.txt b/ChangeReqLab_merged.txt deleted file mode 100644 index 279444bbf..000000000 --- a/ChangeReqLab_merged.txt +++ /dev/null @@ -1,224 +0,0 @@ -[ChangeReqLab] -CASE Study Lab - -Introduction: Software changes are started by creating a change request. A change request can -be a new feature, a bug fix and improvements. -User stories are short and simple descriptions of features written from the perspective of the -person who desires the new capability. -Objectives: -• To write a user story for an existing software feauture. -• Select a user story for your mandatory individual portfolio assignment. -Classwork: -• Each Team creates a GitHub Fork of the project repository [JHotDraw]. -• In future lab exercises, each team member follow [GitHub flow] to collaborate on projects. -• Select an existing feature in JHotDraw and write the user story. See this list of [existing -features] -• Use [GitHub Projects] -• Create a Card for your User Story and put it in the TODO Backlog. -Portfolio Work: -• Write the User Story for your selected JHotDraw feature. Note this is a an artifact for your -portfolio. - -1 - - [CLLab] -Concept Location Lab - -Introduction: Dynamic program analysis is the analysis of computer software that is performed -by executing programs on a real or virtual processor. For dynamic program analysis to be effective, -the target program must be executed with sufficient test inputs to produce interesting behavior. -Use of software testing measures such as code coverage helps ensure that an adequate slice of the -program’s set of possible behaviors has been observed -Objectives: -• Apply the IDE Debugger to locate feature concepts at runtime. -• Create a list of initial set of classes of the concept location results. -Classwork: -• Use the IDE Debugger to localize the classes that involves your Change Request. Features -are often started from the controller classes. Note, if your feature involves a large number of -classes then localize only the domain classes that are related to the to domain concepts. -Portfolio Work: -• Write the initial set of classes in table format as a result of your concept location based on -your selected feature. The table format is as below: -Domain Class - -Responsibility - -1 - - [AnalysisLab] -Impact Analysis Lab - -Introduction: Change impact analysis (IA) can be defined as ”identifying the potential consequences of a change, or estimating what needs to be modified to accomplish a change”. -Objectives: -• Apply static and dynamic analysis to find the estimated impacted set of classes based on -your Change request. -Classwork: -• Find The Estimated Impact Set of classes by following the activities illustrated in Figure 7.9 -in [Raj13]. - -Portfolio Work: Use Table 1 to list the packages and the number of classes you visited after you -located the concept. Write short comments explaining what you have learned about each package -and how they contribute to your feature? - -1 - - Package name - -# of classes - -Comments - -Table 1: The list of all the packages visited during impact analysis. - -2 - - [CILab] -Impact Continues Integration Lab - -Introduction: In software engineering, continuous integration (CI) is the practice of merging -all developers’ working copies to a shared mainline several times a day [Tho]. Grady Booch first -proposed the term CI in his 1991 method although he did not advocate integrating several times -a day [Boo]. Extreme programming (XP) adopted the concept of CI and did advocate integrating -more than once per day – perhaps as many as tens of times per day [Bec99]. -Objectives: -• Understand what CI is. -• Setup a simple CI pipeline. -Classwork: -1. Go to [Building and testing Java with Maven] -2. Add a *.yml file to your repository path /.github/workflows/ to tell -GitHub Actions CI what to do. -3. Configure the *.yml to automatically build your project for each pull request (use maven). -4. To use shared jars from GitHub Packages you need create a .maven-settings.xml file in -the project root folder, see [Working with the Apache Maven registry] -5. Configure the *.yml to execute tests automatically. - -References -[Bec99] Kent Beck. Embracing change with extreme programming, 1999. [HTML]. -[Boo] - -Grady Booch. Object Oriented Design: With Applications. [HTML]. - -[Tho] - -ThoughtWorks. Continues Integration. [HTML]. - -1 - - [RefactLab] -Refactoring Lab -Jan Corfixen Sørensen -Introduction: Refactoring is a disciplined technique for restructuring an existing body of code, -altering its internal structure without changing its external behavior. Its heart is a series of small -behavior preserving transformations. Each transformation (called a ”refactoring”) does little, but a -sequence of these transformations can produce a significant restructuring. Since each refactoring is -small, it’s less likely to go wrong. The system is kept fully working after each refactoring, reducing -the chances that a system can get seriously broken during the restructuring. -Objectives: -• Identify and understand Bad Code Smells. -• Apply refactorings to get rid of Bad Code. -Classwork: -• Make sure you have your own feature branch, using “git checkout -b your-feature development”. -• Please follow the feature branch workflow [GitHub flow]. -• Install [sonarlint]. -• Find Code smells in JHotDraw based on your change request and sonarlint (shouldn’t be a -problem). -• Apply one or more suitable Refactoring Patterns to get rid of the bad code smells 1 . -Portfolio Work: -• Describe the code smell that triggered your refactoring, see Chapter 4 in [Ker05]. Describe -what you plan to change by refactoring. Describe the strategy of the refactorings. Which of -the refactorings from [Ker05] did you apply and what was the reasoning behind it? -• Remember to describe the strategies and purpose of the Refactorings. - -1 See http://refactoring.com/catalog/ - -1 - - [ActLab] -Actualization Lab -Jan Corfixen Sørensen -Introduction: The actualization phase consists of the implementation of the new functionality, -its incorporation into the old code, and change propagation that seeks out and updates all places -in the old code that require secondary modification. -Objectives: -• Understand and explain Clean Architecture in context of Actualization -• Understand and explain Clean Code Principles in context of Actualization -Portfolio Work: -• Provide examples of the SOLID principles in context of the CASE study. -• Explain Clean Architecture in context of the CASE Study. -• - -1 - - [ActLab] -Actualization Lab -Jan Corfixen Sørensen -Introduction: The actualization phase consists of the implementation of the new functionality, -its incorporation into the old code, and change propagation that seeks out and updates all places -in the old code that require secondary modification. -Objectives: -• Understand and explain Clean Architecture in context of Actualization -• Understand and explain Clean Code Principles in context of Actualization -Portfolio Work: -• Provide examples of the SOLID principles in context of the CASE study. -• Explain Clean Architecture in context of the CASE Study. -• - -1 - - [TestLab1] -Testing - -Introduction: In computer programming, unit testing is a software testing method by which -individual units of source code—sets of one or more computer program modules together with -associated control data, usage procedures, and operating procedures—are tested to determine -whether they are fit for use. Unit tests are typically automated tests written and run by software -developers to ensure that a section of an application (known as the ”unit”) meets its design and -behaves as intended. In procedural programming, a unit could be an entire module, but it is -more commonly an individual function or procedure. In object-oriented programming, a unit is -often an entire interface, such as a class, but could be an individual method. By writing tests -first for the smallest testable units, then the compound behaviors between those, one can build up -comprehensive tests for complex applications. -Objectives: -• Understand the importance of testing. -• Implement unit tests. -Classwork: -1. Add maven dependency to [JUnit4] if it is not already done. -2. Create JUnit 4 tests for most important domain logic methods of your feature. Note: Swing -and JUnit extensions often works best with JUnit 4. -3. Write JUnit tests for best case scenario -4. Write JUnit tests for identified boundary cases -(a) A unit test should test a single code-path through a single method. When the execution -of a method passes outside of that method, you have a dependency and should apply -mocks/stubs to avoid the dependency, see [mockito.org]. -5. Use JAVA Assertions to test invariants, see [JAVA Asserts]. -(a) Assertions should be used to check something that should never happen -(b) Note, an assertion should stop the program from running, but an exception should let -the program continue running. -Portfolio Work: -• At class level write unit tests of important business functionality of your selected Feature. -Document how you have verified your Feature. - -1 - - [TestLab2] -Behavior Driven Testing - -Introduction – User Stories and BBD -User stories are short and simple descriptions of capabilities written from the perspective of the -person who desires the new capability. “As a [user type], I want [some goal] so that -[some reason].” An alternative includes: “As a [user type], I want [some goal] - -because [why].” -Mapping User Stories to BDD: - -Figure 1: Example of how to map User Story to BDD scenario. - -Portfolio: -• Map your User Stories to BDD Given-When-Then Scenarios -• Use [JGiven] to automate your BDD Scenarios -• For domain specific assertions use the [AssertJ library]. -For Swing applications use the [AssertJ-swing] to automate the Scenarios. - -1 - - \ No newline at end of file diff --git a/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/FormatExtension.java b/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/FormatExtension.java index 8b22d8c6e..f37e3420e 100644 --- a/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/FormatExtension.java +++ b/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/FormatExtension.java @@ -1,10 +1,3 @@ -/* - * @(#)FormatExtension.java - * - * Copyright (c) 2025 The authors and contributors of JHotDraw. - * You may not use, copy or modify this file, except in compliance with the - * accompanying license terms. - */ package org.jhotdraw.draw.io; import java.util.Arrays; @@ -17,35 +10,17 @@ public final class FormatExtension { private final String extension; - /** - * Creates a new format extension. - * - * @param extension the file extension (without leading dot) - * @throws IllegalArgumentException if extension is null or empty - */ public FormatExtension(String extension) { if (extension == null || extension.trim().isEmpty()) { throw new IllegalArgumentException("Extension cannot be null or empty"); } - // Normalize to lowercase for consistent comparison this.extension = extension.trim().toLowerCase(); } - /** - * Returns the normalized extension string. - * - * @return the extension in lowercase - */ public String getValue() { return extension; } - /** - * Checks if this extension matches the given string (case-insensitive). - * - * @param other the string to compare - * @return true if they match - */ public boolean matches(String other) { if (other == null) { return false; @@ -53,12 +28,6 @@ public boolean matches(String other) { return extension.equalsIgnoreCase(other.trim()); } - /** - * Creates a set of FormatExtension objects from an array of strings. - * - * @param extensions array of extension strings - * @return immutable set of FormatExtension objects - */ public static Set createSet(String... extensions) { if (extensions == null || extensions.length == 0) { return Collections.emptySet(); diff --git a/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/ImageFormatProvider.java b/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/ImageFormatProvider.java index 712535e8e..a6dd96701 100644 --- a/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/ImageFormatProvider.java +++ b/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/ImageFormatProvider.java @@ -4,46 +4,15 @@ public interface ImageFormatProvider { - /** - * Returns the format name (e.g., "PNG", "JPEG"). - * - * @return the format name - */ String getFormatName(); - /** - * Returns a human-readable description of the format. - * - * @return the format description - */ String getDescription(); - /** - * Returns the file extensions supported by this format. - * - * @return array of file extensions (without dots) - */ String[] getFileExtensions(); - /** - * Returns the MIME types supported by this format. - * - * @return array of MIME types - */ String[] getMimeTypes(); - /** - * Creates an input format for reading images of this type. - * - * @param prototype the prototype figure for holding the image - * @return an InputFormat instance - */ InputFormat createInputFormat(ImageHolderFigure prototype); - /** - * Creates an output format for writing images of this type. - * - * @return an OutputFormat instance, or null if output is not supported - */ OutputFormat createOutputFormat(); } diff --git a/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/ImageFormatRegistry.java b/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/ImageFormatRegistry.java index 782642ef2..3fde4aefd 100644 --- a/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/ImageFormatRegistry.java +++ b/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/ImageFormatRegistry.java @@ -1,10 +1,3 @@ -/* - * @(#)ImageFormatRegistry.java - * - * Copyright (c) 2025 The authors and contributors of JHotDraw. - * You may not use, copy or modify this file, except in compliance with the - * accompanying license terms. - */ package org.jhotdraw.draw.io; import org.jhotdraw.draw.figure.ImageHolderFigure; @@ -13,30 +6,14 @@ import java.util.List; import java.util.ServiceLoader; -/** - * A registry for image format handlers that provides a modular way to - * add support for various image formats (PNG, JPEG, GIF, etc.). - * - *

This class uses the Service Provider Interface (SPI) pattern to allow - * dynamic registration of image format handlers.

- * - *

Usage:

- *
- * // Get all registered input formats for a prototype figure
- * List<InputFormat> formats = ImageFormatRegistry.getInputFormats(myImageFigure);
- * drawing.getInputFormats().addAll(formats);
- * 
- */ public final class ImageFormatRegistry { private static final List providers = new ArrayList<>(); static { - // Register default providers registerProvider(new PngFormatProvider()); registerProvider(new JpegFormatProvider()); - // Load additional providers via SPI ServiceLoader loader = ServiceLoader.load(ImageFormatProvider.class); for (ImageFormatProvider provider : loader) { registerProvider(provider); @@ -44,44 +21,22 @@ public final class ImageFormatRegistry { } private ImageFormatRegistry() { - // Prevent instantiation } - /** - * Registers a new image format provider. - * - * @param provider the provider to register - */ public static void registerProvider(ImageFormatProvider provider) { if (provider != null && !providers.contains(provider)) { providers.add(provider); } } - /** - * Unregisters an image format provider. - * - * @param provider the provider to unregister - */ public static void unregisterProvider(ImageFormatProvider provider) { providers.remove(provider); } - /** - * Returns all registered providers. - * - * @return an unmodifiable list of providers - */ public static List getProviders() { return Collections.unmodifiableList(providers); } - /** - * Creates input formats for all registered image format providers. - * - * @param prototype the prototype figure to use for creating image holders - * @return a list of input formats - */ public static List createInputFormats(ImageHolderFigure prototype) { List formats = new ArrayList<>(); for (ImageFormatProvider provider : providers) { @@ -90,11 +45,6 @@ public static List createInputFormats(ImageHolderFigure prototype) return formats; } - /** - * Creates output formats for all registered image format providers. - * - * @return a list of output formats - */ public static List createOutputFormats() { List formats = new ArrayList<>(); for (ImageFormatProvider provider : providers) { @@ -106,12 +56,6 @@ public static List createOutputFormats() { return formats; } - /** - * Checks if a specific format is supported. - * - * @param extension the file extension (e.g., "png", "jpg") - * @return true if the format is supported - */ public static boolean isFormatSupported(String extension) { String ext = extension.toLowerCase(); for (ImageFormatProvider provider : providers) { diff --git a/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/JpegFormatProvider.java b/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/JpegFormatProvider.java index 275950fd8..614b74409 100644 --- a/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/JpegFormatProvider.java +++ b/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/JpegFormatProvider.java @@ -1,21 +1,8 @@ -/* - * @(#)JpegFormatProvider.java - * - * Copyright (c) 2025 The authors and contributors of JHotDraw. - * You may not use, copy or modify this file, except in compliance with the - * accompanying license terms. - */ package org.jhotdraw.draw.io; import org.jhotdraw.draw.figure.ImageHolderFigure; import java.awt.image.BufferedImage; -/** - * Provider for JPEG (Joint Photographic Experts Group) image format. - * - *

JPEG uses lossy compression, making it ideal for photographs - * and images with smooth color gradients. Supports both .jpg and .jpeg extensions.

- */ public class JpegFormatProvider implements ImageFormatProvider { @Override diff --git a/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/PngFormatProvider.java b/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/PngFormatProvider.java index 828043c29..6e8ba86e6 100644 --- a/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/PngFormatProvider.java +++ b/jhotdraw-core/src/main/java/org/jhotdraw/draw/io/PngFormatProvider.java @@ -1,21 +1,8 @@ -/* - * @(#)PngFormatProvider.java - * - * Copyright (c) 2025 The authors and contributors of JHotDraw. - * You may not use, copy or modify this file, except in compliance with the - * accompanying license terms. - */ package org.jhotdraw.draw.io; import org.jhotdraw.draw.figure.ImageHolderFigure; import java.awt.image.BufferedImage; -/** - * Provider for PNG (Portable Network Graphics) image format. - * - *

PNG supports lossless compression and transparency (alpha channel), - * making it ideal for graphics with sharp edges or text.

- */ public class PngFormatProvider implements ImageFormatProvider { @Override