Comments (6)
This was a style choice I made intentionally. I think it's easiest to learn when:
- You only learn a little bit of new stuff at a time
- You repeatedly reinforce what you already know
This pattern is used throughout the book. I think of it as "taking a step into the unknown, and then letting your understanding catch up".
I tried to deliberately make the "new thing" you learn the obvious next step, even when it isn't necessarily the order you'd do things as an expert. For example, you're right that an expert would add the Constants
class early on, because they already know they'll need it. As a beginner reading the book, you don't already know you'll need it. I show the simplest, obvious thing first (hardcoding the string "Administrator"). Then, gently introduce the idea of refactoring it, but only after that string had been used in more than one place.
It does mean that you can't compile the code after every single step. The very next step should always be adding the file you are missing, though.
I'm curious to hear feedback from others on this style. I think it's helpful for beginners, but that might just be me.
from little-aspnetcore-book.
I liked that style as I read through it. However, I'm not a beginner, so I was okay with not being able to compile after each step. At this point in my career, I prefer this style of filling it in one step at a time as opposed to writing something that will compile, and then having to replace most of what you just wrote for the next step (which must also compile).
from little-aspnetcore-book.
@Welkie : I am not talking about replacing the previous code with new one to proceed to the next steps. Only for illustration purpose, for example, if we want to create a new class CCC that needs other classes BBB and AAA, then AAA and BBB should be created first. It is what I meant as forward order like building a house; we start building from the ground level to the higher level.
from little-aspnetcore-book.
I must say I prefer the approach taken in the book. Introduce the simplest new piece of information first and then gradually build up the complexity. Yes, it hurt a little bit when typing a "magic string" into the attribute, but then it was a relief later on to refactor it out into a constants class. I think this is the best approach for beginners and to be honest, how I code most of the time as well. If you take the YAGNI approach, like @nbarbettini said, it's only after you use the string a few times that you think 'hmm, maybe this needs to be in a constants class'. If you only ever end up using it in one place, then you ain't gonna need a constants class.
from little-aspnetcore-book.
I agree with @GarethOates. The approach where you cause a problem and solve it like with the constants class is great because it can help beginner programmers recognize the situations in the future as they code where they'd want to fix those magic strings with a constant. I know this is a subject where people will disagree, but I definitely liked the style @nbarbettini used to write the book. It's what lead to me finishing it and what drew me to this repo.
from little-aspnetcore-book.
Thanks for the feedback everyone! I've made some small changes in version 1.1 (out today) that explain a few things earlier, but overall I've kept this style as I think it works well.
from little-aspnetcore-book.
Related Issues (20)
- Portuguese (pt-br) Translation HOT 28
- Facebook login HOT 1
- Generate a more secure first-time admin password HOT 1
- Page 93: for technical reasons you cannot use await in Program.cs HOT 1
- Page 90: missing using System.Linq in the SeedData.cs HOT 2
- Identity exception HOT 3
- Possible typo on page 94 HOT 2
- Compatibility with ASP.NET Core 2.1 HOT 13
- Error "Create a migration" HOT 2
- Security and Identity chapter missing the creating of ApplicationUser Model HOT 1
- Update testing chapters - how to test with Identity
- Issue after publishing to azure
- Table Row Strikethrough Not Working
- Missing instructions for "deploying to IIS"? HOT 2
- Update The Context Clarification HOT 4
- Hi, Anyone is planning work into improve this book? HOT 1
- Update to Asp.Net Core 3.1 HOT 2
- Italian translation and Asp.Net Core 3.1 update HOT 1
- Unable to download Mobi or ePub versions of the book HOT 1
- I'm getting an error on page 51 Update the context HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from little-aspnetcore-book.