creature
Joined 14 years ago
Joined 14 years ago
Frameworks are a big help – partially for the tools they provide, but also for the consistency. "We have a lot of code, but it's all structured in a standard way" makes things easier to understand. It's also a way of having confidence in the architecture: you know many other people have built successful apps with it, rather than something you've invented yourself.
The concepts in Redux are very appealing to me: your application has one state, and that state gets changed via actions. You have a function that, given a state and an action, produces a new state. Your application can render itself from that state. This makes testing straightforward: your business logic tests boil down to "Given this starting state, and this action, my output state should look like this." Similarly, your UI is now easy to test: "Given this state, my component should render like this," covers displaying information, and "When I interacted with this element, was an action emitted?" covers user interaction. Traditionally hairy areas are now more straightforward: "I need to test with a logged-in user" or "I need to test a successful payment" is all about the data in the state.
Another technique you can use is a publish/subscribe architecture: individual parts of your application publish events, and can subscribe to events they care about. Now, your InboxCounter widget doesn't have to know anything about how messages are received or displayed; as long as it listens for "message:added" and "message:removed" events, it can display an accurate count. Similarly, the AJAX polling for new messages doesn't need to be coupled to the message display or the counters or other elements; it just has to check for new messages, and publish events when new ones are received. This should make it easier to add new components and refactor old ones (as long as you're emitting the same events, nothing else should have to be updated), but it can be hard to figure out what events get emitted, and where they come from. Tests help.
On a much smaller level, using promises instead of callbacks can help reduce "pyramid code" - sections of the codebase with extreme indentation. They also make it easier to handle failure cases; writing "Make these 3 co-dependent AJAX requests, and if any fail then display an error message" will be more concise and clearer with promises.
Finally, don't over-complicate things. Frameworks, dependency injection, and the like add a lot of upfront complexity to a project, but reduce it later on. If all your application needs is an occasional "When X happens, show/hide this DOM element" then simple jQuery event listeners will be a lot quicker to build and easier to understand. Don't build a Swiss watch when what you needed was an egg timer.
The two that come to mind are when cooking ("Hey Siri, set a timer for 15 minutes") or when I'm trying to get everything together for leaving the house ("Hey Siri, how cold is it outside?"). I'll also use it if my phone's in my pocket, I'm wearing headphones, and it's awkward to get my phone out ("Hey Siri, text Tom." "What do you want to say to Tom?" "I'm running 10 minutes late but will be there soon. Sorry!")
Also, if you're working as a developer already then the first year of university is likely to be straightforward for you. Depending on the hours, you could probably keep the part-time job and study (but out of the two, you should prioritise the study).
Finally, I'd recommend you use your free time in university well. Volunteer for charitable organisations; help out with your student union; take up a sport; keep learning things not on the curriculum. All of these are fulfilling in and of themselves, but will also benefit your future too.
I make programming jokes on Twitter: http://twitter.com/acreature You can find out more on my website: http://alexpounds.com/