Skip to content

Code Refactoring based on SOLID Principles #6

@eimmy-o

Description

@eimmy-o

Hi developers
I was looking through your code and found some SOLID principles that were being violated, here are my suggestions on how to fix it:

In Cloud.java, the interface had too many responsibilities, so it's better if you separate each responsibility in one interface on its own:
public interface Loggin { public boolean login(String userName, String password); }

public interface Upload { public void upload(String file); }

public interface Download { public String download(String file); }

Leaving Cloud just handeling the files, like this:
public interface Cloud { public void listFiles(); }

Now in Fly.java, interface that implements Bird, the main issue is Penguin causing the method fly() throw an error, since penguins cannot fly, instead I suggest the next model:

UML Diagram
image

And finally in CaoCloaud.java you're using a direct object of CloudImp, taking advantage of the interfaces i suggested to creat in the problem with Cloud, we can fix it using your own class AbstractClouad.java and the interfaces, adding a new interface for FastDownload, something like this:

UML Diagram
image

That would be all, thanks for reading and I hope this helps a little :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions