Other Patterns

Model-View-Controller (MVC)

The Model-View-Controller (MVC) pattern has been around for a long while and is used by many programming languages, I am only going to briefly touch on this subject as it is vast. The MVC pattern uses three parts

The image below represents how the flow of data uses the MVC pattern


The user interacts with the view (generally a web page) this interacts with the controller (preforms routing) which then uses the model to retrieve data (generally from a database). This type of setup is used by many, many websites on the internet and many web frameworks like Django use the MVC pattern.

The reason to use the MVC pattern is as follows:

MVC example (very basic)
# Model-View-Controller (MVC) example
class Model(object):
    services = {
        'email': {'number': 1000, 'price': 2, },
        'sms': {'number': 1000, 'price': 10, },
        'voice': {'number': 1000, 'price': 15, },
    }


class View(object):
    def list_services(self, services):
        print('\t', end='')
        for svc in services:
            print(svc, end=' ')
        print()

    def list_pricing(self, services):
        for svc in services:
            print("For", Model.services[svc]['number'], svc, "message you pay $", Model.services[svc]['price'])


class Controller(object):
    def __init__(self):
        self.model = Model()
        self.view = View()

    def get_services(self):
        services = self.model.services.keys()
        return self.view.list_services(services)

    def get_pricing(self):
        services = self.model.services.keys()
        return self.view.list_pricing(services)


class Client(object):
    controller = Controller()

    print("Services Provided:")
    controller.get_services()

    print("\nPricing for Services:")
    controller.get_pricing()


def main():
    client = Client()


if __name__ == "__main__":
    main()

Anti-Pattern

An Anit-Pattern is a common response to a recurring problem that is usually ineffective and risks being highly counterproductive using Robert Martin's example there are four aspects to bad design:

Anti-Patterns may result because the developer does not understand software development processes, or not not use the correct design pattern for the problem. There are two Anti-Patterns classifications:

Software development Anti-Pattern When redesigning the application and particular software development refectoring is taken with a negative view by many, although it provides software designers to look at data structures and scalability, but this does comes as a cost. This leads to what is know as spaghetti code, code that is complex to read and test.
Software architecture Anti-Pattern the architecture is more about the modelling of the application, which involves developers, testing teams, mangers and other stakeholders. In this area its all about not reventing the wheel, so this leads you to reuse old code or not refactor old code, thus leading to many problems down the road.

The other area that causes Anti-Patterns is vendor locking, which means that you are dependent on a 3rd parties code, if the company is not keeping up with the times this restricts you on what you can do and even make you design something more or less on the same design that you originally started out with.

To summarize an AntiPattern is a literary form that describes a commonly occurring solution to a problem that generates decidedly negative consequences.