Code Review, Critique & Use Of Software Engineering Practices Assignment Sample

Fotoshop Prototype Critique, Design Patterns & Software Engineering Practices Analysis for Improved Image Manipulation Software

  • 54000+ Project Delivered
  • 500+ Experts 24x7 Online Help
  • No AI Generated Content
GET 35% OFF + EXTRA 10% OFF
- +
35% Off
£ 6.69
Estimated Cost
£ 4.35
11 Pages 2868Words

Code Review, Critique & Use Of Software Engineering Practices Assignment

Functionality as well as the structure of a given prototype/ diagram

Overview of the functionality and structure of the prototype

The prototype developed by the intern from the University of Sarre is an image manipulation program called ‘Fotoshopdeveloped using Java. It takes user input commands through the command line interface to manipulate images. The available commands include 'open' to load an image as the current workable image, 'save' to save the current working image to a file, 'help' to provide a list of instructions, 'quit' to exit the program, 'look' to report the status of the workbench, 'mono' to convert the current workable image to monochrome, 'rot90' to rotate the image 90 degrees, and 'script' to run a script of commands from a file.

New Assignment Help is synonymous with excellence in assignment writing services in the UK. Our dedicated team is committed to delivering impeccable assignments that exceed your expectations.

The program's structure is based on a simple prototype and is not designed to be easily extendable. The program does not have a core, underlying structure that can be reused in future versions of the product. The future plans of the company, which include an image cache, undo operation, support for internationalization, and further filters, require significant changes to the current codebase. The program's functionality is limited and only allows for basic image manipulation (Wijoyo et al. 2021). The program's structure is also limited and lacks the necessary cohesion and coupling required for future development. Overall, the current prototype is insufficient for meeting the company's ambitions, and significant changes are required to make it more functional and extensible.

Class diagram

The class diagram above represents the current implementation of the image manipulation program, ‘Fotoshop’. The program is structured using the Model-View-Controller (MVC) pattern, where the model is represented by the Editor and Image classes, the controller is represented by the Parser class, and the view is represented by the CommandWords class. The CommandWords class is responsible for validating user commands by maintaining a list of valid commands and checking if the user input matches any of them (Alahmadi et al. 2020). The Parser class parses the user input and creates a Command object that encapsulates the user's intent. The Editor class is responsible for loading, editing, and saving images. It has an ImageLoader dependency, which loads the image file, and a Filter dependency, which applies filters to the image. The Image class represents an image and has attributes for width and height.

The class diagram shows a lack of separation of concerns and high coupling between classes. For example, the Editor class has both image loading and image editing responsibilities, which violates the Single Responsibility Principle. Additionally, the Parser class depends on the CommandWords class, which creates a tight coupling between the two. These design issues make the code difficult to maintain and extend.

Main critique

Identification of the main issues

The main issues which can be identified from the above-illustrated code are given below

  • The Editor class's “function Object () {[native code]}” accepts four arguments of the type null. This is not ideal and might lead to problems while running. It would be preferable to give concrete values to support these claims.
  • Before using the “edit ()” function on the editor object, the “set ()” method is invoked. This might not correspond to the proper sequence of events, depending on how these procedures are applied (Syaifudin et al. 2020).
  • This code does not primarily handle exceptions or errors. Handling potential problems that may be generated during the execution of the program is always an effective solution.

The main issues which can be identified from the above-suggested code are given below

  • There is no error handling in the code. It will merely provide a blank command if a parsing problem occurs. It would be preferable to deal with errors and let the user know whether there are any problems.
  • The code includes magic numbers like 0 and 1 that were used to extract the “first and second words” from the input. To make the code more legible and maintainable, it would be preferable to utilize named constants or variables (Zhao et al. 2019).
  • Variable naming incongruity is one of the major issues. The reader variable is referred to as an "input stream" and as a “source of command input" in numerous circumstances. Moreover, consistent variable names ought to be utilized throughout the above-mentioned code.

Editor

The critical issues which can be identified from the above-suggested code are mentioned below

  • The filter variables are initialized to null within the Editor class' “function Object () {[native code]}" and this does not make use of the input arguments. Moreover, it should be noted that it can result in unexpected behaviour. Therefore, it needs to be corrected by initializing the appropriate variables with the input parameters.
  • In the absence of code that changes the parser object, the “set () function” is not invoked and appears to be unnecessary (Haase et al. 2020).
  • The “IOException” is caught by the loadImage () method, which also produces a notice, but it is not appropriately handled or propagated. Depending on the particular use case, it would be preferable to either rethrow an exception or provide a “0”.

These are the probable issues with the code:

  • It is always an array of strings called “validCommands”. However, it should be noted that they are not arranged alphabetically. Constant arrays ought to be continually kept sorted to make navigating across them easier. The array can be sorted using the “Arrays. sort () method”.
  • Moreover, until a match is discovered, the loop in “isCommand” repeats over each entry in “validCommands”. This can take a while if there is a large array of valid commands. To accelerate the search, consider trying to substitute a “HashSet” for an array, which is a more effective data structure (Malkadi et al. 2020).
  • Allowing case-insensitive matches would increase the flexibility of the “isCommand function”. Before comparing them, using the “LowerCase () or toUpperCase ()” function to change the case including both validCommands[i] and aString to lowercase or uppercase can be adopted.

Command

These are the probable as well as critical issues within the code:

  • The “secondWord” value, rather than the thirdWord value, can be seen as being used in terms of setting the thirdWord variable in the function “Object () {[native code]}”. Swapping this out should be a possible approach. In this case “thirdWord” = “secondWord” should be taken as a strategic case.
  • The “secondWord” variable is returned by the getThirdWord () method rather than “thirdWord”. In this regard, “Return thirdWord” can be used in place of “return secondWord”.
  • On the other hand, variable names need to be improved throughout the ‘command code’ code. To more clearly express their meaning and purpose, “firstWord”, “secondWord”, and “thirdWord” can each be altered to “command”, “parameter1”, and “parameter2”, respectively.

Colour image

The issues which can be found from the above code are given below

  • It is critical to consider documentation to the class component that describes its function as well as intended use.
  • On the other hand, offering input validation to the “setPixel” method in terms of confirming that perhaps the ‘y’ and ‘x’ parameters are contained within the boundaries of the image.
  • In addition to this, input validation in the “getPixel” technique is to make sure the y and x parameters are included within the boundaries of the image (Bao et al. 2020).
  • In case the “BufferedImage” supplied to the “ColorImage” function “Object () {[native code]}” is null, adding error handling can do the job.

Static code analysis

Tool 1: PMD Eclipse

First two issues

It can be seen that the File input stream instead of new file inputs is the primary issue that can be identified in the static analysis. Java's FileInputStream class allows one to read "data from files" (). In order to define the file to read from, it is frequently used in combination with File objects. One problem with utilizing FileInputStream is that there is a chance of running into a “FileNotFoundException” in case of supplying a String (Karvelas et al. 2020). This indicates a file path straight into its function “Object () {[native code]}” and thus it appears that the file cannot be “located at that location”.

Making sure that handling any "FileNotFoundException" that might occur while using "FileInputStream" is the primary method of mitigating this particular issue.

Tool 2: PMD IntelliJ

It can be seen that there is an invalid return statement which is identified as a second issue by the PMD. In this regard, this is critical to ensure that all return statements follow a particular method. Moreover, it is also important to mention that, the return type of the method must be matching the type significantly specified in the “method signature”.

Second two issue

The above image shows that here for-each loop is used in place of for loop. It is because of fast method to execute. This implementation gives less error in the code compare to the for loop. It can be seen that loop use has been considered a critical issue with a static analysis tool. A “for Each” loop should be used instead of a “for loop” in terms of iterating over the collections. It should be mentioned that the “for Each” loop is known for its concise behaviour as well as less error-prone attributes (Niephaus et al. 2019).

Moreover, there are always issues around keeping track of the currently available indexes, which can be error-prone, especially when the loop body modifies the collection. Modification of the list during the iteration can effectively result in ConcurrentModificationException which is a major problem with the for loop. In this regard, using an iterator in terms of removing elements can be the best option.

The above image shows the programs which helps to assigning values again and again without repeating the existing codes. It is very essential because the program takes less time to execute. It can be seen from the above figure that avoiding reassigning values to the given variables should be a critical issue. In such a case, the program should be affected in terms of functionality and effectivity. At the same time, there is a major issue with command line execution. In this regard, mitigation actions like reassigning values should be adopted for saving execution time (Mountapmbeme et al. 2022).

A design pattern that refactors the prototype as well as an example implementation within the Java

Identify and discussion on the design pattern

It does follow some basic principles of good software design, such as separation of concerns and modularity. The process command method is a good example of the separation of concerns. It takes a Command object as input and is responsible for interpreting the command and calling the appropriate methods based on the command word. This allows the main game logic to be kept separate from the command processing logic, making the code easier to understand and maintain (Lukkarinen et al. 2021). The code also appears to be modular, with each command being handled by a separate method. This helps to keep the code organized and makes it easier to modify or extend the functionality in the future. While the code may not use any specific design pattern, it does demonstrate some good principles of software design.

Class diagram

The above class diagram is suggesting on a design pattern that can be implemented in terms of better functionality of the application (Bednarik et al. 2020).

Four commands

The above image shows the commands which are used for taking input image and complete some tasks. The tasks are defined by some command lines which performs the exact task by giving output image. It can be seen from the above figure that four major commands that are based on the class diagram have been given. In this regard, the first command is suggesting that open input is based on the class diagram. At the same time, the second command is to look. On the other hand, the rot90 command can directly help in terms of rotating the image 90 degrees. Similarly, the saving output command should be directly helping in terms of saving the file (Weintrop and Wilensky, 2019). Henceforth, it can be said that, through the help of these four major commands, this application can perform better.

Unit testing

The four functionality errors have been identified in the previous section of the report.

Version control

It can be seen from the above figure that this project has been used in terms of the Git repository. In such a case, the above screenshot is suggesting the effective creation of the Git repository.

It can be seen from the above figure that Fotoshop private GitHub repository has been created with effective execution of the strategy. Thus, it can be said that the creation of the private Git hub repository has directly suggested on the effective completion of the scope.

References

  • ACM Technical Symposium on Computer Science Education (pp. 759-765). Niephaus, F.,
  • Alahmadi, M., Khormi, A., Parajuli, B., Hassel, J., Haiduc, S. and Kumar, P., 2020. Code localization in programming screencasts. Empirical Software Engineering, 25, pp.1536-1572.
  • Bao, L., Xing, Z., Xia, X., Lo, D., Wu, M. and Yang, X., 2020. psc2code: Denoising code extraction from programming screencasts. ACM Transactions on Software Engineering and
  • Bednarik, R., Busjahn, T., Gibaldi, A., Ahadi, A., Bielikova, M., Crosby, M., Essig, K., Fagerholm, F., Jbara, A., Lister, R. and Orlov, P., 2020. EMIP: The eye movements in programming dataset. Science of Computer Programming, 198, p.102520.
  • Conference on Software Engineering (ICSE) (pp. 350-361). IEEE.
  • deployment using multi-lingual code generation. bioRxiv, pp.2020-11. Malkadi, A., Alahmadi,
  • Felgentreff, T. and Hirschfeld, R., 2019, October. Graalsqueak: Toward a smalltalk-based tooling platform for polyglot programming. In Proceedings of the 16th acm sigplan international conference on managed programming languages and runtimes (pp. 14-26).
  • Funabiki, N., Kuribayashi, M. and Kao, W.C., 2020. A proposal for Android programming learning assistant system with the implementation of basic application learning. International Journal of Web Information Systems, 16(1), pp.115-135.
  • Haase, R., Jain, A., Rigaud, S., Vorkel, D., Rajasekhar, P., Suckert, T., Lambert, T.J.,
  • Interactive design of GPU-accelerated image data flow graphs and cross-platform
  • Karvelas, I., Li, A. and Becker, B.A., 2020, February. The effects of compilation mechanisms and error message presentation on novice programmer behavior. In Proceedings of the 51st
  • Lukkarinen, A., Malmi, L. and Haaranen, L., 2021. Event-driven programming in programming education: a mapping review. ACM Transactions on Computing Education (TOCE), 21(1), pp.1 31.
  • and Haiduc, S., 2020, June. A study on the accuracy of our engines for source code transcription from programming screencasts. In Proceedings of the 17th International Conference on Mining Software Repositories (pp. 65-75).
  • Methodology (TOSEM), 29(3), pp.1-38.
  • Mountapmbeme, A., Okafor, O. and Ludi, S., 2022. Addressing Accessibility Barriers in Programming for People with Visual Impairments: A Literature Review. ACM Transactions on Accessible Computing (TACCESS), 15(1), pp.1-26.
  • Nunez-Iglesias, J., Poole, D.P., Tomancak, P. and Myers, E.W., 2020.
  • Syaifudin, Y.W.,
  • Weintrop, D. and Wilensky, U., 2019. Transitioning from introductory block-based and text-based environments to professional programming languages in high school computer science classrooms. Computers & Education, 142, p.103646.
  • Wijoyo, H., Haudi, H., Sunarsi, D., Cahyono, Y., Wijayanti, K.D., Nuryani, Y., Nariah, N. and Akbar, M.F., 2021. Design of Information System Buddhist Identity Card in Riau Province Using Java Programming Language. Available at SSRN 3865597.
  • Zhao, D., Xing, Z., Chen, C., Xia, X. and Li, G., 2019, May. ActionNet: Vision-based workflow actionrecognition from programming screencasts. In 2019 IEEE/ACM 41st International

 

35% OFF
Get best price for your work
  • 54000+ Project Delivered
  • 500+ Experts 24*7 Online Help

offer valid for limited time only*

×