|
1 |
| -# JetBrains Academy Java Course Template |
2 |
| - |
3 | 1 | [](https://confluence.jetbrains.com/display/ALL/JetBrains+on+GitHub)
|
4 |
| -[](https://opensource.org/licenses/MIT) |
5 |
| - |
6 |
| -> **Note** |
7 |
| -> |
8 |
| -> Click the <kbd>Use this template</kbd> button and clone it in IntelliJ IDEA. |
9 |
| -
|
10 |
| -**JetBrains Academy Java course template** is a repository that provides a |
11 |
| -pure template to make it easier to create a new Java course with the [JetBrains Academy |
12 |
| -plugin][ref:plugin.marketplace] (check out the [Creating a repository from a template][gh:template] article). |
| 2 | +[](https://github.com/jetbrains-academy/refactoring-java-course/actions/workflows/gradle-build.yml) |
13 | 3 |
|
14 |
| -The main goal of this template is to speed up the setup phase |
15 |
| -of Java course development for both new and experienced educators |
16 |
| -by preconfiguring the project scaffold and CI, |
17 |
| -linking to the proper documentation pages, and keeping everything organized. |
| 4 | +# Introduction to IDE Code Refactoring in Java |
18 | 5 |
|
19 |
| -If you're still not quite sure what this is all about, read our introduction: [What is the JetBrains Academy plugin?][docs:intro] |
| 6 | +This course will introduce you to refactorings and the IDE features that will help you to perform them in an effective way. |
| 7 | +You will learn to recognize refactoring opportunities in code and to deal with them. |
| 8 | +Using automatic IDE refactorings, you will transform code to improve its structure, readability, and maintainability. |
20 | 9 |
|
21 |
| -> **Note** |
22 |
| -> |
23 |
| -> Click the <kbd>Watch</kbd> button on the top to be notified about releases containing new features and fixes. |
| 10 | +The course consists of 8 sections. Each section focuses on one group of refactorings and |
| 11 | +provides brief theory and several small tasks for practice. |
| 12 | +We will move on from small local refactoring changes to more complex ones, which affect the entire project architecture. |
24 | 13 |
|
25 |
| -### Table of contents |
| 14 | +Topics covered: |
26 | 15 |
|
27 |
| -In this README, we will highlight the following elements of template-project creation: |
| 16 | +- refactoring definition; |
| 17 | +- code quality and code smells; |
| 18 | +- kinds of refactoring techniques; |
| 19 | +- IDE refactoring features; |
| 20 | +- code style and formatting; |
| 21 | +- code style schema and EditorConfig; |
| 22 | +- automatic formatting using IDE; |
| 23 | +- naming rules; |
| 24 | +- rename refactoring; |
| 25 | +- move refactoring; |
| 26 | +- pull up and push down refactoring; |
| 27 | +- extract refactoring; |
| 28 | +- inline refactoring; |
| 29 | +- design patterns and their relationships with refactoring. |
28 | 30 |
|
29 |
| -- [Getting started](#getting-started) |
30 |
| -- [Gradle configuration](#gradle-configuration) |
31 |
| -- [Course info configuration file](#course-info-configuration-file) |
32 |
| -- [Course ignore file](#course-ignore-file) |
33 |
| -- [Sample code](#sample-code) |
34 |
| -- [Testing](#testing) |
35 |
| -- [Predefined Run/Debug configurations](#predefined-rundebug-configurations) |
36 |
| -- [Continuous integration](#continuous-integration) |
37 |
| -- [Useful links](#useful-links) |
38 |
| - |
39 |
| -## Getting started |
40 | 31 |
|
41 |
| -Before we dive into course development and everything related to it, it's worth mentioning the benefits of using GitHub Templates. |
42 |
| -By creating a new project with the current template, you start with no history or reference to this repository. |
43 |
| -This allows you to create a new repository easily, without copying and pasting previous content, cloning repositories, or clearing the history manually. |
| 32 | +## Technical requirements |
44 | 33 |
|
45 |
| -All you need to do is click the <kbd>Use this template</kbd> button (you must be logged in with your GitHub account). |
| 34 | +Before starting this course, check the following requirements. |
46 | 35 |
|
47 |
| -![Use this template][file:use-template-blur] |
| 36 | +1. Your computer needs to have a stable internet connection. |
| 37 | +2. Git version control system needs to be installed on your computer (link to the git site: https://git-scm.com/). |
| 38 | +3. Make sure that the path to the root folder of the course does not contain spaces, special characters, or non-Latin characters. |
| 39 | +4. Make sure that you use the [IntelliJ IDEA](https://www.jetbrains.com/idea/download/?_ga=2.189310830.494255415.1682514714-1823138827.1669894241&_gac=1.83806948.1682684894.Cj0KCQjw3a2iBhCFARIsAD4jQB3QkDU43KtbIx2HzEz02KvcN7Ma3QGzkIbyX4KS3H4x8b2bl9p4EfYaAvWsEALw_wcB&_gl=1*1h13lr8*_ga*MTgyMzEzODgyNy4xNjY5ODk0MjQx*_ga_9J976DJZ68*MTY4MjY5NDIyMy4xMjUuMS4xNjgyNjk0MjM4LjQ1LjAuMA..#section=windows) with version at least `2023.1.1`. |
| 40 | +5. Make sure that you use the [JetBrains Academy](https://plugins.jetbrains.com/plugin/10081-jetbrains-academy) plugin with version at least `2023.1`. |
48 | 41 |
|
49 |
| -The most convenient way of getting your new project from GitHub is the <kbd>Get from VCS</kbd> action available on the Welcome Screen, |
50 |
| -where you can filter your GitHub repository by its name. |
51 |
| - |
52 |
| -![Use this template][file:use-this-template.png] |
| 42 | +The course is integrated into the [IntelliJ IDEA IDE](https://www.jetbrains.com/idea/), which has a free Community license. |
| 43 | +You can use this license to complete the course. |
| 44 | +If you have some troubles with the course installation, feel free to contact us by email at [email protected]. |
53 | 45 |
|
| 46 | +## Getting started |
54 | 47 |
|
55 |
| -As the last step, you need to manually review the configuration variables described in the [`gradle.properties`][file:gradle.properties] file and *optionally* move sources from the *org.jetbrains.academy.java.template* package to the one that works best for you. |
56 |
| -Then you can get to work and implement your ideas. |
| 48 | +This course is [available](https://plugins.jetbrains.com/plugin/23048-introduction-to-ide-code-refactoring) on JetBrains |
| 49 | +Marketplace and can be installed from the IntelliJ IDEA IDE directly, but you can also use it in the Course Creator mode |
| 50 | +or create a course archive from the source code. |
57 | 51 |
|
58 |
| -## Gradle configuration |
| 52 | +### Getting started: create a course preview from the source code |
59 | 53 |
|
60 |
| -The recommended method for Java course development involves using the [Gradle][gradle] setup. |
| 54 | +You can create a [course preview](https://plugins.jetbrains.com/plugin/10081-jetbrains-academy/docs/educator-start-guide.html#preview_course) from the source code: |
| 55 | +1. Clone the repository: |
| 56 | + ```text |
| 57 | + git clone https://github.com/jetbrains-academy/refactoring-java-course.git |
| 58 | + ``` |
61 | 59 |
|
62 |
| -A course built using the JetBrains Academy Java course template includes a Gradle configuration already set up. |
63 |
| -This gradle file sets up all base dependencies and plugins for the course. |
64 |
| -For each gradle module (each task in the course and extra modules like `common` as well) |
65 |
| -it includes [JUnit5][ref:junit5] tests. |
66 |
| -It also marks the `source` and `test` folders as source- and test- source sets in the project. |
| 60 | +2. Build the project: |
| 61 | + ```text |
| 62 | + ./gradlew build |
| 63 | + ``` |
67 | 64 |
|
68 |
| -### Gradle properties |
| 65 | +3. Install the [JetBrains Academy](https://plugins.jetbrains.com/plugin/10081-jetbrains-academy/docs/install-jetbrains-academy-plugin.html) plugin from JetBrains Marketplace. |
69 | 66 |
|
70 |
| -The project-specific configuration file [`gradle.properties`][file:gradle.properties] contains: |
| 67 | +4. Create a new [course preview](https://plugins.jetbrains.com/plugin/10081-jetbrains-academy/docs/educator-start-guide.html#preview_course). |
71 | 68 |
|
72 |
| -| Property name | Description | |
73 |
| -|---------------------|---------------------------------------------------------------| |
74 |
| -| `courseGroup` | Package name. | |
75 |
| -| `courseVersion` | The current version of the course in [SemVer][semver] format. | |
76 |
| -| `gradleVersion` | Version of Gradle used for course development. | |
77 |
| -| `jvmVersion` | Version of the JVM used for course development. | |
| 69 | +### Getting started: create a course archive |
78 | 70 |
|
79 |
| -## Course template structure |
| 71 | +You can create a [course archive](https://plugins.jetbrains.com/plugin/10081-jetbrains-academy/docs/educator-start-guide.html#fe7010f2) from the source code: |
| 72 | +1. Clone the repository: |
| 73 | + ```text |
| 74 | + git clone https://github.com/jetbrains-academy/refactoring-java-course.git |
| 75 | + ``` |
80 | 76 |
|
81 |
| -A generated JetBrains Academy Java Course Template repository contains the following content structure: |
| 77 | +2. Build the project: |
| 78 | + ```text |
| 79 | + ./gradlew build |
| 80 | + ``` |
82 | 81 |
|
83 |
| -``` |
84 |
| -. |
85 |
| -├── .github/ GitHub Actions workflows |
86 |
| -├── .run/ Predefined Run/Debug Configurations |
87 |
| -├── build/ Output build directory |
88 |
| -├── gradle |
89 |
| -│ └── wrapper/ Gradle Wrapper |
90 |
| -├── common Course sources common for all sections |
91 |
| -│ └── src |
92 |
| -│ └── main |
93 |
| -│ ├── java/ Java production sources |
94 |
| -│ └── resources/ Resources - images, icons |
95 |
| -├── courseSection/ An example of the course section |
96 |
| -│ ├── courseLesson/ An example of the course lesson |
97 |
| -│ │ ├── theoryTask/ An example of a theory task |
98 |
| -│ │ │ ├── src/ Task sources |
99 |
| -│ │ │ │ └── ... |
100 |
| -│ │ │ ├── task.md Task/theory description |
101 |
| -│ │ │ └── task-info.yaml Task config file |
102 |
| -│ │ ├── quizTask/ An example of a quiz task |
103 |
| -│ │ │ ├── src/ Task sources |
104 |
| -│ │ │ │ └── ... |
105 |
| -│ │ │ ├── task.md Task/quiz description |
106 |
| -│ │ │ └── task-info.yaml Task config file |
107 |
| -│ │ ├── programmingTask/ An example of a programming task |
108 |
| -│ │ │ ├── src/ Task sources |
109 |
| -│ │ │ │ └── ... |
110 |
| -│ │ │ ├── test/ Task tests |
111 |
| -│ │ │ │ └── ... |
112 |
| -│ │ │ ├── task.md Task description |
113 |
| -│ │ │ └── task-info.yaml Task config file |
114 |
| -│ │ └── lesson-info.yaml Lesson config file |
115 |
| -│ ├── courseFrameworkLesson/ An example of the course framework lesson |
116 |
| -│ │ ├── ... Several examples of lessons |
117 |
| -│ │ └── lesson-info.yaml Lesson config file |
118 |
| -│ └── section-info.yaml Section config file |
119 |
| -├── .courseignore Course ignoring rules |
120 |
| -├── .gitignore Git ignoring rules |
121 |
| -├── build.gradle.kts Gradle configuration |
122 |
| -├── course-info.yaml Course info configuration file |
123 |
| -├── gradle.properties Gradle configuration properties |
124 |
| -├── gradlew *nix Gradle Wrapper script |
125 |
| -├── gradlew.bat Windows Gradle Wrapper script |
126 |
| -├── LICENSE License, MIT by default |
127 |
| -├── README.md README |
128 |
| -└── settings.gradle.kts Gradle project settings |
129 |
| -``` |
| 82 | +3. Install the [JetBrains Academy](https://plugins.jetbrains.com/plugin/10081-jetbrains-academy/docs/install-jetbrains-academy-plugin.html) plugin from JetBrains Marketplace. |
130 | 83 |
|
131 |
| -## Course info configuration file |
132 |
| - |
133 |
| -The course info configuration file is the [course-info.yaml][file:course-info.yaml] file located in the root directory. |
134 |
| -It provides general information about the course, like description, language, etc. |
135 |
| - |
136 |
| -```yaml |
137 |
| -type: marketplace |
138 |
| -title: JetBrains Academy Java course template |
139 |
| -language: English |
140 |
| -summary: Course description |
141 |
| -programming_language: Java |
142 |
| -content: |
143 |
| - - courseSection |
144 |
| -environment_settings: |
145 |
| - jvm_language_level: JDK_17 |
146 |
| -``` |
| 84 | +4. Create a new [course archive](https://plugins.jetbrains.com/plugin/10081-jetbrains-academy/docs/educator-start-guide.html#fe7010f2). |
147 | 85 |
|
148 |
| -## Course ignore file |
| 86 | +## Run tests |
149 | 87 |
|
150 |
| -The course ignore file is the [.courseignore][file:courseignore] file located in the root directory. |
151 |
| -It provides the list of files or directories that will be ignored in the final course preview or archive. |
| 88 | +To run tests locally, you just need to build the project and run the following command: |
152 | 89 |
|
153 | 90 | ```text
|
154 |
| -README.md |
155 |
| -/.run |
| 91 | +./gradlew test |
156 | 92 | ```
|
157 | 93 |
|
158 |
| -You can find more information about the course preview in the [Course preview][ref:course.preview] section. Information |
159 |
| -about creating a course archive and uploading it to the marketplace is in the [Course distribution][ref:course.distribution] section. |
160 |
| - |
161 |
| -## Sample code |
162 |
| - |
163 |
| -The prepared template provides an example of a course with one section, two lessons, and five tasks in total. |
164 |
| - |
165 |
| -![Course structure in the course creator mode][file:course-structure-author] |
166 |
| - |
167 |
| -Each course may have an unlimited number of sections, lessons, and tasks. |
168 |
| -Students will see almost the same course structure as the educator (course author): |
169 |
| - |
170 |
| -![Course structure in the course student mode][file:course-structure-student] |
171 |
| - |
172 |
| -The main difference is in framework lessons, which display |
173 |
| -only task files, without intermediate steps. |
174 |
| - |
175 |
| -You can read more about framework lessons in the official documentation in the [Framework Lessons Creation][ref:framework.lessons.creation] section. |
176 |
| - |
177 |
| -> **Note** |
178 |
| -> |
179 |
| -> Click <kbd>Course Creator</kbd> -> <kbd>Create Course Preview</kbd> in the context menu in the root of the repository to create a course preview. |
180 |
| -
|
181 |
| - |
182 |
| -The JetBrains Academy plugin provides five different types of tasks, |
183 |
| -and you can combine them inside one lesson (whether regular or framework). |
184 |
| -You can read more about tasks in the official documentation in the [Task][ref:tasks] section. |
185 |
| - |
186 |
| -## Testing |
187 |
| - |
188 |
| -To check the programming exercises for [**edu**][ref:tasks] tasks, you need to write tests. |
189 |
| -It contains functionality to test student solutions by using the [Java Reflection API][ref:java.reflection.api] under the hood. |
190 |
| -This approach allows you to call students' functions that do not exist yet. |
191 |
| -It is a powerful mechanism that enables you to create excesses without predefined classes or function |
192 |
| -templates and check their signature and behaviour properly. |
193 |
| - |
194 |
| -You can find little examples of programming tasks in the repository in the `Tests.java` files: |
195 |
| -in [course lesson][file:course.lesson.tests] and [course framework lesson][file:course.framework.lesson.tests]. |
196 |
| - |
197 |
| -## Predefined Run/Debug configurations |
198 |
| - |
199 |
| -Within the default project structure, there is a `.run` directory provided, which contains predefined *Run/Debug configurations* that expose corresponding Gradle tasks: |
200 |
| - |
201 |
| -![Run/Debug configurations][file:run-debug-configurations] |
202 |
| - |
203 |
| -| Configuration name | Description | |
204 |
| -|--------------------------|--------------------------------------------------------------------------------| |
205 |
| -| Build course | Runs `:build` Gradle task with tests only. | |
206 |
| - |
207 |
| -## Continuous integration |
208 |
| - |
209 |
| -Continuous integration depends on [GitHub Actions][gh:actions], a set of workflows that make it possible to automate your testing and release process. |
210 |
| -Thanks to such automation, you can delegate the testing and verification phases to the Continuous Integration (CI) and instead focus on development (and writing more tests). |
211 |
| - |
212 |
| -In the `.github/workflows` directory, you can find definitions for the following GitHub Actions workflows: |
213 |
| -- [Build](.github/workflows/gradle-build.yml) |
214 |
| - - Builds your course |
215 |
| - - Runs all tests for all tasks |
216 |
| - |
217 |
| -## Useful links |
218 |
| - |
219 |
| -- [JetBrains Academy plugin][ref:plugin.marketplace] |
220 |
| -- [Course creator start guide][ref:course.creator.start.guide] |
221 |
| -- [Courses on Marketplace][ref:marketplace] |
222 |
| - |
223 |
| -[gh:actions]: https://help.github.com/en/actions |
224 |
| -[gh:template]: https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template |
225 |
| - |
226 |
| -[ref:marketplace]: https://plugins.jetbrains.com/education |
227 |
| -[ref:course.creator.start.guide]: https://plugins.jetbrains.com/plugin/10081-jetbrains-academy/docs/educator-start-guide.html |
228 |
| -[ref:plugin.marketplace]: https://plugins.jetbrains.com/plugin/10081-jetbrains-academy |
229 |
| -[ref:course.preview]: https://plugins.jetbrains.com/plugin/10081-jetbrains-academy/docs/educator-start-guide.html#preview_course |
230 |
| -[ref:course.distribution]: https://plugins.jetbrains.com/plugin/10081-jetbrains-academy/docs/educator-start-guide.html#course_distribution |
231 |
| -[ref:framework.lessons.creation]: https://plugins.jetbrains.com/plugin/10081-jetbrains-academy/docs/framework-lessons-guide-for-course-creators.html#a81e8983 |
232 |
| -[ref:tasks]: https://plugins.jetbrains.com/plugin/10081-jetbrains-academy/docs/framework-lessons-guide-for-course-creators.html#a81e8983 |
233 |
| -[ref:java.reflection.api]: https://docs.oracle.com/javase/8/docs/technotes/guides/reflection/index.html |
234 |
| -[ref:junit5]: https://junit.org/junit5/ |
235 |
| - |
236 |
| -[docs:intro]: https://plugins.jetbrains.com/plugin/10081-jetbrains-academy/docs/jetbrains-academy-plugin-faq.html#what_is_the_jetbrains_academy_plugin |
| 94 | +The tests use the Java Reflection API under the hood to check the user's tasks. |
237 | 95 |
|
238 |
| -[file:gradle.properties]: ./gradle.properties |
239 |
| -[file:course-info.yaml]: ./course-info.yaml |
240 |
| -[file:courseignore]: .courseignore |
241 |
| -[file:course.lesson.tests]: ./courseSection/courseLesson/programmingTask/test/Tests.java |
242 |
| -[file:course.framework.lesson.tests]: ./courseSection/courseFrameworkLesson/programmingTask/test/Tests.java |
| 96 | +## Want to know more? |
243 | 97 |
|
244 |
| -[gradle]: https://gradle.org |
| 98 | +If you have questions about the course or the tasks or if you find some errors, |
| 99 | +you can ask questions and participate in discussions in repository [issues](https://github.com/jetbrains-academy/refactoring-java-course/issues). |
245 | 100 |
|
246 |
| -[semver]: https://semver.org |
| 101 | +## Contribution |
247 | 102 |
|
248 |
| -[file:use-this-template.png]: common/src/main/resources/images/get-from-version-control.png |
249 |
| -[file:course-structure-author]: common/src/main/resources/images/course-structure-author.png |
250 |
| -[file:course-structure-student]: common/src/main/resources/images/course-structure-student.png |
251 |
| -[file:run-debug-configurations]: common/src/main/resources/images/run-debug-configurations.png |
252 |
| -[file:use-template-blur]: common/src/main/resources/images/use_template_blur.jpg |
| 103 | +Please be sure to review the [project's contributing guidelines](./contributing.md) to learn how to help the project. |
0 commit comments