Bladeren bron

Update README.md

Git-Leon 6 jaren geleden
bovenliggende
commit
c2f8e4bef7
Geen account gekoppeld aan de committers e-mail
1 gewijzigde bestanden met toevoegingen van 178 en 1 verwijderingen
  1. 178
    1
      README.md

+ 178
- 1
README.md Bestand weergeven

@@ -1 +1,178 @@
1
-# CR-MesoLabs-Beans.LearnerLab-
1
+# Bean Flavored Learner Lab
2
+* **Objective** - to implement a `ZipCodeWilmington` class which _mediates_ a _composite_ `Students` and `Instructors` _singleton_ reference.
3
+* **Purpose** - to demonstrate the use of
4
+	* Bean registration
5
+	* Dependency Injection
6
+	* IOC Container
7
+	* `AnnotationConfigApplicationContext`
8
+	* Annotations
9
+		* `@Bean`
10
+		* `@DependsOn`
11
+		* `@Autowired`
12
+		* `@PostConstruct`
13
+		* `@Config`
14
+		* `@SpringBootTest`
15
+		* `@Resource`
16
+
17
+
18
+## Developmental Notes
19
+* You may structure this project and the packaging how you please, however keep in mind that `@Configuration` scans from current directory down.
20
+
21
+### Part 0.0 - Generating Project
22
+* Navigate to [start.spring.io](start.spring.io)
23
+* Search for `Web` in the `Search for Dependencies` input box
24
+* Select `Generate Project`
25
+* After the project has completed downloading, navigate to the download directory and unzip the project folder.
26
+* After unzipping the project folder, open the project via its `pom.xml` from IntelliJ > File > Open
27
+	* Be sure to `Open as Project` when prompted 
28
+
29
+
30
+### Part 1.0 - Create `Person` Class
31
+* Create a `Person` class.
32
+	* The class should declare a `final` field named `id` of type `long`.
33
+	* The class should declare a field named `name` of type `String`.	
34
+	* `Person` constructor should have a parameter of type `long` which sets the `id` field to the respective value.
35
+	* The class should define a `getId()` method which returns the `Person` object's `id` field.
36
+	* The class should define a `getName()` method which returns the `Person` object's `name` field.
37
+	* The class should define a `setName()` method which sets the `Person` object's `name` field.
38
+
39
+-
40
+### Part 2.0 - Create `Learner` Interface
41
+* Create a `Learner` interface.
42
+	* `Learner` should declare one method signature:
43
+		* Method name: `learn`
44
+		* Method parameters: `double numberOfHours`
45
+		* Method return-type: `void`
46
+
47
+-
48
+### Part 3.0 - Create `Student` Class
49
+* Create a `Student` class such that:
50
+	* `Student` is a subclass of `Person`
51
+	* `Student` implements the `Learner` interface
52
+	* `Student` should have an instance variable `totalStudyTime` of type `double`
53
+	* `Student` should have a concrete implementation of the `learn` method which increments the `totalStudyTime` variable by the specified `numberOfHours` argument.
54
+	* `Student` should have a `getTotalStudyTime()` method which returns the `totalStudyTime` instance variable.
55
+
56
+
57
+-
58
+### Part 4.0 - Create `Teacher` Interface
59
+* Create a `Teacher` interface.
60
+	* `Teacher` should declare a `teach` method signature:
61
+		* Method name: `teach`
62
+		* Method parameters:
63
+			* `Learner learner`
64
+			* `double numberOfHours`
65
+		* Method return-type: `void` 
66
+
67
+	* `Teacher` should declare a `lecture` method signature:
68
+		* Method name: `lecture`
69
+		* Method parameters:
70
+			* `Learner[] learners`
71
+			* `double numberOfHours`
72
+		* Method return-type: `void`
73
+
74
+		
75
+-
76
+### Part 5.0 - Create `Instructor` Class
77
+* Create an `Instructor` class such that:
78
+	* `Instructor` is a subclass of `Person`
79
+	* `Instructor` implements the `Teacher` interface
80
+	* `Instructor` should have a concrete implementation of the `teach` method which invokes the `learn` method on the specified `Learner` object.
81
+	* `Instructor` should have a concrete implementation of the `lecture` method which invokes the `learn` method on each of the elements in the specified array of `Learner` objects.
82
+		* `numberOfHours` should be evenly split amongst the learners.
83
+			* `double numberOfHoursPerLearner = numberOfHours / learners.length;`
84
+
85
+-
86
+### Part 6.0 - Create `Students` 
87
+* Create a `Students` class.
88
+	* The class should be an _unextendable_ subclass of the `People` class.
89
+	* The class should consume a variable number of `Student` objects upon construction and pass them to the super constructor.
90
+
91
+-
92
+### Part 7.0 - Create `Instructors` 
93
+* Create a `Instructors` class.
94
+	* The class should be an _unextendable_ subclass of the `People` class.
95
+	* The class should consume a variable number of `Instructor` objects upon construction and pass them to the super constructor.
96
+
97
+
98
+
99
+-
100
+### Part 8.0 - Create `Classroom`
101
+* Create a `Classroom` class.
102
+	* The class should consume and set composite reference to an `Instructors` and `Students` object upon construction
103
+	* The class should define a method `hostLecture` which makes use of a `Teacher teacher, double numberOfHours` parameter to host a `lecture` to the composite `personList` field in the `students` reference.
104
+	
105
+
106
+-
107
+## Part 9.0 - Creating `Configuration` classes
108
+* Each of the following `Config` classes should have a class-signature annotation of `@Configuration`
109
+	* this annotation tells spring to scan for `@Bean` definitions within the scope of the class, and register them to the [IOC Container](https://www.tutorialspoint.com/spring/spring_ioc_containers.htm) for `Inject` and `Autowire` use later.
110
+
111
+-
112
+### Part 9.1 - Create `StudentConfig`
113
+* **Note:** The creation of this class will demonstrate an implementation of bean registration in Spring.
114
+* The class should define a method named `currentStudents()` which returns a `Students` representative of the current cohort of students.
115
+	* the method should be annotated with `@Bean(name = "students")`
116
+		* this ensures the Spring container registers the bean with the respective name.
117
+		* a `@Bean` whose `name` attribute is not specified defaults to the name of the method it is annotating.
118
+* The class should define a bean named `previousStudents()` which returns a `Students` representative of the previous cohort of students.	
119
+
120
+-
121
+### Part 9.2 - Create `InstructorsConfig`
122
+* The class should define a bean named `tcUsaInstructors()` which returns an `Instructors` representative of the Tech Connect USA instructors.
123
+* The class should define a bean named `tcUkInstructors()` which returns an `Instructors` representative of the Tech Connect UK instructors.
124
+* The class should define a bean named `allInstructors` which returns all `Instructors` employed at ZipCodeWilmington
125
+
126
+
127
+
128
+-
129
+### Part 9.3 - Create `ClassroomConfig`
130
+* The class should define a bean named `currentCohort()` which returns an `Classroom` object whose dependencies are `allInstructors` and `students`
131
+* The class should define a bean named `previousCohort()` which returns an `Classroom` object whose dependencies are `allInstructors` and `previousStudents`
132
+* **Note:** [it is sometimes useful](https://www.boraji.com/spring-dependson-annotation-example) (although not always necessary) to use the `@DependsOn` annotation to help the compiler and other readers of the code to understand what order beans should be executed.
133
+	* `@DependsOn({"allInstructors", "students"})`
134
+
135
+	
136
+
137
+
138
+-
139
+## Part 10 - Test `Config` classes
140
+* Each of the following `Test` classes should be annotated with
141
+	* `@SpringBootTest`
142
+		* indicates that this class is a Spring Boot test class
143
+		* provides support to scan for a `ContextConfiguration` that tells the test class how to load the `ApplicationContext`.
144
+		* If no `ContextConfiguration` classes are specified as a parameter to the `@SpringBootTest` annotation, the default behavior is to load the `ApplicationContext` by scanning for a `@SpringBootConfiguration` annotation on a class in the package root.
145
+* Each bean can be injected into the class scope using `@Autowired` along with `@Resource(name = "beanname")`
146
+
147
+
148
+
149
+-
150
+### Part 10.1 - Test `StudentConfig` Class
151
+* Create a `TestStudentConfig` class in the `test` package.
152
+* The class should ensure that each `Bean` in the `StudentConfig` class is configured as expected.
153
+* **Tip:** You can use the `toString` method to get a representation of the aggregate state of any `People` object.
154
+
155
+
156
+-
157
+### Part 10.2 - Test `InstructorConfig` Class
158
+* Create a `TestInstructorConfig` class in the `test` package.
159
+* The class should ensure that each `Bean` in the `TestInstructorConfig` class is configured as expected.
160
+
161
+
162
+-
163
+### Part 10.3 - Test `ClassroomConfig` Class
164
+* Create a `TestClassroomConfig` class in the `test` package.
165
+* The class should ensure that each `Bean` in the `TestClassroomConfig` class is configured as expected.
166
+
167
+-
168
+### Part 11 - Create `Alumni` Class
169
+* Create an `Alumni` class which autowires `Students` of the previous and `Instructors`
170
+* Annotate the class signature class with `@Component`
171
+	* The annotation allows Spring to register this class as a `Bean` implicitly.
172
+* Create an `executeBootcamp` method which teaches each `Student` in the composite `Students` a `totalNumberOfHours` of `1200`.
173
+	* Annotate this method with `@PostConstruct`
174
+		* denotes that this method must be executed before the class is put into an IoC container
175
+
176
+-
177
+### Part 11.1 - Test `Alumni` Class
178
+* Write a test class which ensures that each `Student` in the `Alumni` class has been taught `1200` hours upon injection of the `Alumni` dependency.