Showing posts with label mvc. Show all posts
Showing posts with label mvc. Show all posts

This Week I Learned 2018 - Week 51

Last week post or something else from the past years.

Are we at the end of hardware virtualization performance? Yes, according to the trend of the Amazon EC2 Virtualization Types. However, in the end, we just go back to bare metal somehow. The rapid improvement in virtualization made setting up homelab and data hoarding possible, cheap, and fast.

Meanwhile, what the heck is Firecracker (official announcement from Amazon)? New virtualization tool based on Kernel-based Virtual Machine (KVM). Interestingly, checking its Git repo indicates that the project was written in Rust, due to its origin started from Chrome OS Virtual Machine Monitor (crosvm), which was written in Rust. Why? Serverless platform, and for Amazon, the removal of VM like Fargate which leads to further cost reduction. Similar, Nitro, the Amazon latest hypervisor, also leverages on KVM but only the core modules to achieve near bare metal performance.

How do you automatically clean up orphaned Docker containers, instances, volumes, networks, or images? If you use Docker for your daily development, your environment accumulates these leftover artifacts unless you're diligent enough to do the clean up yourself. My "research" (ahem, googling) found two tools, docker-gc and docker-clean. The former is written in Golang and thus make it more portable compare to the later in Bash. But why such feature is not built into Docker itself?

What the heck is MVC-L? A concept popularized by OpenCart. Nothing fancy, just an additional Language (L) layer added to the pattern. Combine with another existing extension pattern to MVC, HMVC, we will have HMVCL. Is software pattern still a thing these days?

Is being an independent ISP still a thing in 2018? Yes, it still is, especially in rural area. Whole infrastructure is based on Ubiquiti and Microtik hardware.

How to update parent state from child component in React? Callback in the parent component as a prop to the child component. Treat each component as a class and props as parameters passed to the instance of the class itself. The basis concept is quite straight forward and what was I thinking?

In the parent component.
render() {
    return <Child action={this.handler} />

In the child component.
render() {
    return <Button onClick={this.props.action} />

Legacy Code Base

Due to some unforeseen reason, I took a quick look over two legacy code base in the system to fix certain issues. The more I looked at it, the more my stress level shoot up. I literally want to strangle the original programmers or anyone near me.

Yes, the module or feature did almost work as intended but modification or bug fixing is a pain in the arse. I have to suppress my inner urge multiple times the whole day thinking of whether to do a total rewrite or refactor of the module. I kept shaking my head whether I should fix the bug first or refactor the damn module while fixing it.

Framework, especially Model-view-controller (MVC) framework provides a good initial structure for creating an application. At least, you have the advantage of separation of concerns (SoC) between all these three layers. However, problems arise when we're deciding on what or how to separate a program into these sections. I've seen many types of abuse of the MVC framework especially those lack of Object-Oriented (OO) mindset. While we have idiom like "Fat Models, Skinny Controller" exists as a guideline, it still, can lead to another form of abuse like God Models.

The lesson I've learned is that rather than taking the best engineering approach to design a system, instead use the most suitable solution understandable by the technical competency of the available programmers. You can't change a procedural to OO mindset as well as their egos instantly. Especially true for senior programmer as they said, old habits dies hard. If the basic understanding of MVC and OO is seriously lacking, might as well take what Ramus Lerdorf proposed "no-framework PHP MVC framework" approach. At least it is more procedural and understandable by most PHP programmer.