Software Designing_First Attempt From Copycatting

Tim is just getting onto it, so I will follow through. The first clip is on the thinking process. Before jumping into the codes, first take some time to think deep and through, then draw down the design such as the below one for a school educational system.

Implementing the above UML diagram into codes, each block gets a folder, corresponding to a class. First, Person class,

from address import Address

class Person:

def __init__(self, first, last dob, phone, address):
self.first_name = first
self.last_name = last
self.date_of_birth = dob
self.phone = phone
self.addresses = []

if isinstance(address, Address):
self.addreses.append(address)
elif isinstance(address, list):
for entry in address:
if not isinstance(entry, Address):
raise Error(“Invalid Addrss…”)
self.addresses = address
else:
raise Error(“Invalid Address…”)

def add_address(self, address):
if not isinstance(address, Address):
raise Error(“Invalid Addrses…”)

elf.address.append(address)

On similar thought logic, continue creating the rest of the classes, such as Course in course folder:

from professor import Professor
from enroll import Enroll

class Course:
def __init__(self, name, code, max_, min_, professor):
self.name = name
self.code = code
self.max = max_
self.min = min_
self.professors = []
self.enrollments = []

if isinstance(professor,Professor):
self.professors.append(professor)
elif isinstance(professor, list):
for entry in professor:
if not isinstance(entry, Professor):
raise Error(“Invalid professor…”)

self.professors = professor
else:
raise Error(“Invalid professor…”)

def add_professor(self, professor):
if not isinstance(professor, Professor):
raise Error(“Invalid professor…”)

self.professors.append(professor)

def add_enrollment(self, enroll):
if not isinstance(enroll, Enroll):
raise Error(“Invalid Enroll”)

if len(enrollments) == self.max:
raise Error(“Cannot enroll, course if full…”)

self.enrollments.append(enroll)

def is_cancelled(self):
return len(self.enrollments) < self.min

Now my overarching goal is to streamline regular tools/methods I’ve been using into a package so it’s scalable and efficient. I would start from copycatting a domino pizza ordering API design then dive into our own team’s API design both analytical and CTS teams.

Check out the github page, the diagram

Then dive into our own API packages. One is CTS API, which still seems incomplete other than lots of specs. The other is PA API Engine API.

The structure of the latter is as below. The main classes are deeply buried down in multiple layers.

The detailed scripts are available at the link. The entire design is quite complex hard to grasp from browsing it…

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.