DEV Community

Cover image for SOFTWARE DESIGN: FROM WORDS INTO CODES PART II
Michael_Maranan
Michael_Maranan

Posted on • Updated on

SOFTWARE DESIGN: FROM WORDS INTO CODES PART II

SOFTWARE DESIGN: FROM WORDS INTO CODES PART II

In the last article I wrote which is the "SOFTWARE DESIGN: FROM WRITTEN REQUIREMENTS INTO CODES PART I", I discuss making an Entity-Relationship diagram or ER diagram which is for easier analyzation and visualization of our software we are working at. In this article, I'm going to discuss how to code it in a CLI type of app using Python.


The first method I do before jumping on my IDE and starting in any part of it is I make a pseudocode of it, making it more clear and easier to think how it should be implemented in a programming language. I guess you heard about that already. I decided to make each Object a Class and its features are its attributes. To identify where to start to make pseudocode, I try thinking about how this app will work and how it flows. We’re using the same ER diagram and requirements from the last article:
requirements.md:
Image description
ER diagram:
Image description

I. Professor class pseudocode:

class Professor:
    # for adding a new professor in Professor-list
    def create-prof(personal-info,salary):
        professor =  personal-info,salary
        professor.save() in 'Professors-list'

    # adding subject's prof in case it don't have
    def add-subject's-prof(subject,prof-name):
        if subject and prof-name didn't really exist:
            return invalid
        if subject's 'professor' not None:
            return has prof already
        else save subject in prof-name's 'subject-list' & prof-name in subject's 'professor'

    # for computing the professor's salary
    def prof's-salary(prof-name):
        each-subject = 5000
        subject-list-length = prof-name's subjects-list length
        return eachsubject * subject-list-length
Enter fullscreen mode Exit fullscreen mode

II. Subject class pseudocode:

class Subject:
    # for creating a new subject to Subject-list
    def create-subject(name):
        subject = name 
        subject.save() in 'Subject-list'

    # adding subject's prof in case it don't have
    def add-subject's-prof(subject,prof-name):
        if subject and prof-name didn't really exist:
            return invalid
        if subject's 'professor' not None:
            return has prof already
        else save subject in prof-name's 'subject-list' & prof-name in subject's 'professor'

    # add courses related to subject 
    def add-courses-related(subject,course-&-year):
        if subject and course-&-year didn't really exist:
            return invalid
        else save subject in prof-name's 'subject-list' & prof-name in subject's 'professor'        
Enter fullscreen mode Exit fullscreen mode

III. Course class pseudocode:

class Course:
    # making a new course
    def create-course(name,for-year):
        course-name = name,for-year
        course.save() in 'Course-list'

    # add courses related to subject 
    def add-courses-related(subject,course-&-year):
        if subject and course-&-year didn't really exist:
            return invalid
        else save subject in prof-name's 'subject-list' & prof-name in subject's 'professor'

    # enrolling students
    def add-student(student,year-&-course):
        if student and year-&-course didn't really exist:
            return invalid
        if student's course not none:
            return already enrolled
        else save student in course's student-list and course in student's course
Enter fullscreen mode Exit fullscreen mode

IV. Student class pseudocode:

class Student:
    # add a new student
    def create-course(personal-info,course-&-year):
        if course-&-year didn't really exist:
            return invalid
        else:
            course-name = name,for-year
            course.save() in 'Course-list'
Enter fullscreen mode Exit fullscreen mode

Here are some snapshots of my code. I'm not posting the whole picture of it here because it can't fit on my screen. If you want to look at my code, you can visit it here in my github.

Professor

Subject

Course

Student

Oldest comments (0)