SOFTWARE DESIGN: FROM WORDS INTO CODES PART II
Tags: programming, python, database, tutorial
Published: 2022-04-03 12:59:11

# 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"**] (https://dev.to/codeitmichael/software-design-converting-words-into-codes-2loe), 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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wguezsyz7cww1o2ve5k4.png)
`ER diagram:`
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ztvpxxkemewy9hip8k6e.JPG)

### I. `Professor` class pseudocode:
```python
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
```

### II. `Subject` class pseudocode:
```python
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'		
```

### 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
```

### 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'
```

***
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](https://github.com/Codeit-Michael/PySQLite/tree/main/school-CLI).

![Professor](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b331z6t4qyl2qcvf3ok5.png)

![Subject](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zhtmafhm7867mby960kv.png)

![Course](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bftj6cxmvtxhl33zrn70.png)

![Student](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6hwy2nnpgzp2xoqouvoz.png)