From 8d942cc59a0d761f077e43b5731868afc016cd8f Mon Sep 17 00:00:00 2001 From: Ethan McCue Date: Thu, 5 Sep 2024 08:57:36 -0400 Subject: [PATCH] Update (#53) * more sections * First feedback round * Update prelude.md * ... * Spelling fix Co-Authored-By: Firas Regaieg <37019463+firasrg@users.noreply.github.com> * Arguments chapter * More Challenges * Run prettier * user input * October 14th, #1 * Array challenges * Delete challenges * Null * ... * Update null_as_absence.md * Delete out.json * Fix quotes * Add first no_runs * Fix number example * ... * Write more of the classes section * Constructors * Clean up getting started a little * Use a duke * Don't link anywhere yet * Increase lines needed to show a duke * Fix field access section * ... * ... * ... * ... * ... * switch and enums * Update book.toml * Density * Update audience.md * .. * Strings 2 * Update length.md * Global Fields * Input * Update delayed_assignment.md * ... * ... * Update book.js * Update challenges.md * Remove blank Challenge * Fix some issues, push some incomplete sections * Update challenges.md * terminal * Update challenges.md * Switches and visibility * Growable array * Cli Args * Delete unused * Change url * inner classes * Update unchecked_exceptions.md * Update checked_exceptions.md * Update invariants.md * Packages * Records * Update the_default_package.md * Syntax highlighting wierdness * More records * Integers, Files, etc. * Move IOException around * ... * ... * Add new dukes and start hash maps * Start hashmap explanation * Objects * Update README.md * More object chapters * More hash maps * More hash maps * new section headers * Time types * ArrayList * For each loops * recursion * Arraylist recursion and switch * Switch progress --------- Co-authored-by: Firas Regaieg <37019463+firasrg@users.noreply.github.com> --- .github/workflows/linter.yaml | 33 +++-- README.md | 42 +++++- ferris.js | 11 +- src/SUMMARY.md | 136 +++++++++++++------- src/abstract_classes.md | 1 + src/array_list.md | 15 +++ src/array_list/add_an_item.md | 23 ++++ src/array_list/get_an_item.md | 31 +++++ src/array_list/loop_over_items.md | 25 ++++ src/array_list/remove_an_item.md | 91 +++++++++++++ src/array_list/set_an_item.md | 30 +++++ src/array_list/size.md | 27 ++++ src/array_list/ubiquity.md | 14 ++ src/class_extension.md | 1 + src/encapsulation.md | 1 + src/files/creating_a_folder.md | 18 +++ src/files/deleting_a_file.md | 1 + src/files/deleting_a_folder.md | 1 + src/generic_growable_arrays.md | 1 + src/generic_growable_arrays/arraylist.md | 1 + src/generic_hash_maps/hash_map | 1 + src/generics.md | 4 + src/getting_started.md | 10 ++ src/hash_map.md | 1 + src/hash_maps.md | 33 +++++ src/hash_maps/buckets.md | 79 ++++++++++++ src/hash_maps/filing_cabinets.md | 44 +++++++ src/hash_maps/function_range.md | 11 ++ src/hash_maps/get_items.md | 123 ++++++++++++++++++ src/hash_maps/growable_buckets.md | 62 +++++++++ src/hash_maps/hash_collision.md | 14 ++ src/hash_maps/hash_distribution.md | 13 ++ src/hash_maps/hash_functions.md | 31 +++++ src/hash_maps/keys_and_values.md | 12 ++ src/hash_maps/put_items.md | 113 ++++++++++++++++ src/hash_maps/redistribution.md | 1 + src/img/duke_armcross.webp | Bin 0 -> 15082 bytes src/img/duke_computer.webp | Bin 0 -> 15294 bytes src/img/duke_finger.webp | Bin 0 -> 17822 bytes src/interfaces.md | 1 + src/loops_iii.md | 35 +++++ src/multi_dimensional_arrays.md | 1 + src/objects.md | 12 ++ src/objects/array_subtypes.md | 1 + src/objects/equals_and_hashCode.md | 2 + src/objects/instanceof.md | 35 +++++ src/objects/override.md | 57 ++++++++ src/objects/override_equals_and_hashCode.md | 2 + src/objects/override_toString.md | 52 ++++++++ src/objects/recover_types.md | 1 + src/objects/subclasses.md | 4 + src/objects/subtypes.md | 21 +++ src/objects/toString.md | 31 +++++ src/objects/variance_and_casting.md | 5 + src/recursion.md | 37 ++++++ src/recursion/base_case.md | 20 +++ src/recursion/base_cases.md | 1 + src/recursion/comparison_to_delegation.md | 30 +++++ src/recursion/comparison_to_loops.md | 42 ++++++ src/recursion/disclaimer.md | 12 ++ src/switch_iii.md | 31 +++++ src/switch_iii/break.md | 1 + src/switch_iii/default.md | 1 + src/switch_iii/fallthrough.md | 4 + src/switch_iii/return.md | 1 + src/switch_iii/yield.md | 1 + src/time.md | 8 ++ src/time/date.md | 1 + src/time/duration.md | 1 + src/time/instant.md | 4 + src/time/local_date.md | 30 +++++ src/time/local_date_time.md | 20 +++ src/time/local_time.md | 29 +++++ src/time/offset_date_time.md | 1 + src/time/zoned_date_time.md | 1 + 75 files changed, 1524 insertions(+), 67 deletions(-) create mode 100644 src/abstract_classes.md create mode 100644 src/array_list.md create mode 100644 src/array_list/add_an_item.md create mode 100644 src/array_list/get_an_item.md create mode 100644 src/array_list/loop_over_items.md create mode 100644 src/array_list/remove_an_item.md create mode 100644 src/array_list/set_an_item.md create mode 100644 src/array_list/size.md create mode 100644 src/array_list/ubiquity.md create mode 100644 src/class_extension.md create mode 100644 src/encapsulation.md create mode 100644 src/files/deleting_a_file.md create mode 100644 src/files/deleting_a_folder.md create mode 100644 src/generic_growable_arrays.md create mode 100644 src/generic_growable_arrays/arraylist.md create mode 100644 src/generic_hash_maps/hash_map create mode 100644 src/generics.md create mode 100644 src/hash_map.md create mode 100644 src/hash_maps.md create mode 100644 src/hash_maps/buckets.md create mode 100644 src/hash_maps/filing_cabinets.md create mode 100644 src/hash_maps/function_range.md create mode 100644 src/hash_maps/get_items.md create mode 100644 src/hash_maps/growable_buckets.md create mode 100644 src/hash_maps/hash_collision.md create mode 100644 src/hash_maps/hash_distribution.md create mode 100644 src/hash_maps/hash_functions.md create mode 100644 src/hash_maps/keys_and_values.md create mode 100644 src/hash_maps/put_items.md create mode 100644 src/hash_maps/redistribution.md create mode 100644 src/img/duke_armcross.webp create mode 100644 src/img/duke_computer.webp create mode 100644 src/img/duke_finger.webp create mode 100644 src/interfaces.md create mode 100644 src/multi_dimensional_arrays.md create mode 100644 src/objects.md create mode 100644 src/objects/array_subtypes.md create mode 100644 src/objects/equals_and_hashCode.md create mode 100644 src/objects/instanceof.md create mode 100644 src/objects/override.md create mode 100644 src/objects/override_equals_and_hashCode.md create mode 100644 src/objects/override_toString.md create mode 100644 src/objects/recover_types.md create mode 100644 src/objects/subclasses.md create mode 100644 src/objects/subtypes.md create mode 100644 src/objects/toString.md create mode 100644 src/objects/variance_and_casting.md create mode 100644 src/recursion.md create mode 100644 src/recursion/base_case.md create mode 100644 src/recursion/base_cases.md create mode 100644 src/recursion/comparison_to_delegation.md create mode 100644 src/recursion/comparison_to_loops.md create mode 100644 src/recursion/disclaimer.md create mode 100644 src/switch_iii.md create mode 100644 src/switch_iii/break.md create mode 100644 src/switch_iii/default.md create mode 100644 src/switch_iii/fallthrough.md create mode 100644 src/switch_iii/return.md create mode 100644 src/switch_iii/yield.md create mode 100644 src/time.md create mode 100644 src/time/date.md create mode 100644 src/time/duration.md create mode 100644 src/time/instant.md create mode 100644 src/time/local_date.md create mode 100644 src/time/local_date_time.md create mode 100644 src/time/local_time.md create mode 100644 src/time/offset_date_time.md create mode 100644 src/time/zoned_date_time.md diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index 554faa4..0544efa 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -3,21 +3,20 @@ name: Linter on: [pull_request] jobs: - markdown-linter: - name: "Markdown Linter" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 +# markdown-linter: +# name: "Markdown Linter" +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - name: markdownlint-cli +# uses: nosborn/github-action-markdown-cli@v3.2.0 +# with: +# files: . +# config_file: .markdownlint.yaml - - name: markdownlint-cli - uses: nosborn/github-action-markdown-cli@v3.2.0 - with: - files: . - config_file: .markdownlint.yaml - - markdown-link-check: - name: "Markdown Link Checker" - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: gaurav-nelson/github-action-markdown-link-check@1.0.14 +# markdown-link-check: +# name: "Markdown Link Checker" +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v2 +# - uses: gaurav-nelson/github-action-markdown-link-check@1.0.14 diff --git a/README.md b/README.md index aa98b90..5c15e22 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,48 @@ [![codefactor](https://img.shields.io/codefactor/grade/github/together-java/modernjava)](https://www.codefactor.io/repository/github/together-java/modernjava) [![license](https://img.shields.io/github/license/Together-Java/ModernJava)](https://github.com/Together-Java/ModernJava/blob/master/LICENSE) -Book teaching how to write modern and effective Java. It is maintained by the community, anyone can contribute. +Greetings. + +This is a book intended to teach someone the Java language, from scratch. + +You will find that the content makes heavy use of recently released and, for the moment, +preview features. This is intentional as much of the topic ordering doesn't work +without at least Java 21. + +Right now I have several key areas where I could use some help: + +* Writing Challenges. Most of the early sections have challenges students can do to test +their understanding of the topics covered and for practice. I've shifted my focus away from +these to make more progress on the main content of the book. Any assistance would be appreciated. +* Theming. A lot of the chapters are...bland. Purely technical. I find that when I have the imagination to "theme" the subjects they become higher quality and more engaging overall. See +an anime you liked recently and think you can make the math chapters use the characters from it? +Give it a shot! +* Fixing Mechanical Issues. I don't have an editor and I don't often proofread. If you find mechanical errors +in my grammar or find issues with the way topics are ordered I would welcome fixes. + +Notably I do not want to open the floodgates for contributions on the main chapter content +just yet. This has the downside of slower progress but the upside of a more coherent result. + +My primary goals with this are + +* Get the ordering of topics right. By this I mean that every topic covered should have had its pre-requitsites covered in the topics previous. While "lesson 1: Inheritance" is clearly wrong +in this regard, some things are more subtle. +* Be a template for other people. This is a book. Not everyone likes books, some like youtube videos, some like over priced udemy courses, some attend College, etc. Everyone has different learning paths. I hope this to be of use to anyone looking to make a more up to date Java +curriculum and hope that the vague order of things (which I consider superior to the content +produced with the Java of years' past) as carried through. +* Write as if the newest Java wasn't new. Its obvious when a book was written before Java 8 +because it always has newer additions with "addendum: brand new stuff in Java 8." But +the order language features were introduced is hardly a good order to teach them. You have +to pretend that Java 21 has always been *the* Java. Does it really make sense to show terrible +C-style switch statements way before switch expressions? +* Write as if the words Object Oriented Programming, Functional Programming, etc. didn't exist. +While I understand that these all have definitions and are useful concepts to know about, introducing them early seems to lead to either dogma, rejection of said dogma, or some +mix thereof. None of them are actually needed to understand the mechanics of and motivation +behind what we would call "object oriented" or "functional" techniques. They certainly don't +work as justification for adding getters and setters to every class. Feel free to join our [discord server](https://discord.gg/together-java-272761734820003841) -if you have any questions, or require assistance with the project. :relaxed: +if you have any questions, or require assistance with the project. ## Getting started diff --git a/ferris.js b/ferris.js index 5a7f1f6..e74c34c 100644 --- a/ferris.js +++ b/ferris.js @@ -54,7 +54,16 @@ function createFerris(type, size) { a.setAttribute('target', '_blank') var toFileName = function (t) { - return '../img/' + t.attr + '.svg'; + // return '../img/' + t.attr + '.svg'; + if (t.attr == 'panics') { + return '../img/duke_armcross.webp' + } + else if (t.attr == 'does_not_compile') { + return '../img/duke_computer.webp' + } + else if (t.attr == 'not_desired_behavior') { + return '../img/duke_finger.webp' + } } var img = document.createElement('img') diff --git a/src/SUMMARY.md b/src/SUMMARY.md index 173903d..0371702 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -447,6 +447,8 @@ - [Integer to a Base 16 String](./integers_ii/integer_to_a_base_16_string.md) - [Underscores in Integer Literals](./integers_ii/underscores_in_integer_literals.md) +- [🚧 Construction Zone 🚧]() + # Interactive Programs III - [Files](./files.md) @@ -456,64 +458,112 @@ - [Write to a File](./files/write_to_a_file.md) - [Read from a File](./files/read_from_a_file.md) - [Create a Folder](./files/creating_a_folder.md) - - [Delete a Folder](./files/creating_a_folder.md) - - [Delete a File](./files/creating_a_folder.md) + - [Delete a Folder](./files/deleting_a_folder.md) + - [Delete a File](./files/deleting_a_file.md) # Data Structures & Algorithms II -- [Hash Maps]() -- [Hash Sets]() +- [Hash Maps](./hash_maps.md) + - [Filing Cabinets](./hash_maps/filing_cabinets.md) + - [Hash Functions](./hash_maps/hash_functions.md) + - [Function Range](./hash_maps/function_range.md) + - [Buckets](./hash_maps/buckets.md) + - [Hash Collision](./hash_maps/hash_collision.md) + - [Hash Distribution](./hash_maps/hash_distribution.md) + - [Growable Buckets](./hash_maps/growable_buckets.md) + - [Keys and Values](./hash_maps/keys_and_values.md) + - [Put Items](./hash_maps/put_items.md) + - [Get Items](./hash_maps/get_items.md) + # Code Structure IV +- [Object](./objects.md) + - [Subtypes](./objects/subtypes.md) + - [instanceof](./objects/instanceof.md) + - [toString](./objects/toString.md) + - [Override toString](./objects/override_toString.md) + - [@Override](./objects/override.md) + - [equals and hashCode](./objects/equals_and_hashCode.md) + - [Override equals and hashCode](./objects/override_equals_and_hashCode.md) + - [Variance and Casting](./objects/variance_and_casting.md) + - [Subclasses](./objects/subclasses.md) +- [Generics](./generics.md) +- [Interfaces](./interfaces.md) -- [Interfaces]() - - [@Override]() -- [Generics]() - - [Casting]() -- [Object]() - - [instanceof]() - - [toString]() - - [equals]() - - [hashCode]() - - - +- [Time](./time.md) + - [Instant](./time/instant.md) + - [Duration](./time/duration.md) + - [LocalDate](./time/local_date.md) + - [LocalTime](./time/local_time.md) + - [LocalDateTime](./time/local_date_time.md) + - [ZonedDateTime](./time/zoned_date_time.md) + - [OffsetDateTime](./time/offset_date_time.md) +- [ArrayList](./array_list.md) + - [Ubiquity](./array_list/ubiquity.md) + - [Add an item](./array_list/add_an_item.md) + - [Size](./array_list/size.md) + - [Get an item](./array_list/get_an_item.md) + - [Loop over items](./array_list/loop_over_items.md) + - [Set an item](./array_list/set_an_item.md) + - [Remove an item](./array_list/remove_an_item.md) +- [HashMap](./hash_map.md) +- [Multi-Dimensional Arrays](./multi_dimensional_arrays.md) -# Interactive Programs +# Control Flow IV +- [Loops III](./loops_iii.md) + - [For-each loops]() + - [Arrays]() + - [Iterable]() + - [ArrayList]() + - [Reasons to go back]() +- [Switch III](./switch_iii.md) + - [Fallthrough](./switch_iii/fallthrough.md) + - [break](./switch_iii/break.md) + - [default](./switch_iii/default.md) + - [return](./switch_iii/return.md) + - [yield](./switch_iii/yield.md) +- [Recursion](./recursion.md) + - [Disclaimer](./recursion/disclaimer.md) + - [Base Case](./recursion/base_case.md) + - [Comparison to Delegation](./recursion/comparison_to_delegation.md) + - [Comparison to Loops](./recursion/comparison_to_loops.md) +# Code Structure V +- [Class Extension](./class_extension.md) +- [Abstract Classes](./abstract_classes.md) -# The Computing Environment +# Concepts II +- [Encapsulation](./encapsulation.md) + - [Methods]() + - [Classes]() + - [Information Hiding]() +# Building +- [Compilation]() +- [Compile Java Code]() + - [Compile a List of Files]() + - [Specify Where to Find Sources]() + - [Enable Debug Info]() +# Data Types VI +- [StringBuilder]() +- [Pattern]() -# Interactive Programs +