Backend Engineering Skills Are Emphasized Too Heavily for Principal Engineers

There is a bias toward backend engineers at the principal engineer level. This leaves frontend engineers heavily disadvantaged when it comes to promotion time.

When someone says they’re a fullstack engineer, what they usually mean is one of two things: 1) They’re a coding bootcamp grad that has minimal experience with Node.js and an emphasis on the frontend. Or, 2) they’re an experienced backend engineer that knows a little bit of HTML and CSS. A truly fullstack software engineer is a rare find.

That being said, principal engineer job requirements focus almost entirely on backend engineering skills. The companies I’ve worked for in the past have had requirements for expertise in areas like networking, system design, database design, building scalable microservice architecture, or designing fault-tolerant systems.

And while all those things are important, especially for someone at a principal level with a backend emphasis, these lists of requirements are often missing many skills that may be unique to frontend engineers but that are equally important.



Valuable Frontend Skills for Principal Engineers

What about the ability to build scalable design systems? Are you able to build atomic-level components that can be built up into molecules, organisms, templates, and eventually pages? Do you understand what should or should not be included in a design system’s component library? Do you understand how to provide clear design constraints to create a consistent UI while also allowing for flexibility in the usage of your components?

What about the ability to build accessible web applications? Accessibility is an often-overlooked skill but one that is becoming increasingly important, especially for software as a service companies in a competitive market. Are you able to build apps that conform to the WCAG 2.1 AA specifications? Do you understand basic design principles and common UX patterns for various widgets? What’s fascinating about accessibility is that so much of it is provided for you, right out of the box, with HTML. Yet most developers don’t create widgets that are operable using a mouse, a keyboard, and a screen reader, opting instead to focus on mouse users only and to ignore common UX patterns.

What about the ability to think clearly about microinteractions in the app? Are you able to create a seamless user experience that keeps users from becoming disoriented? Are you good at thinking through edge cases in how widgets function? Do you have a good design sense? Do you practice inclusive design? Piggybacking off of the previous paragraph, so much of accessibility is really just usability.

What about the ability to optimize performance on the frontend? Do you understand how dev, peer, and regular dependencies work? Do you understand how to optimize bundle size for your frontend app and how to avoid downloading the same resources multiple times?



Conclusion and Invitation

These kinds of skills and many more are extremely important in frontend architecture, and yet they are rarely included in skills requirements for principal engineers.

My advice to engineering leadership everywhere is to look for the valuable skills that frontend engineers bring to the table and find ways to include those skill sets in your requirements for promotions, especially for those positions at higher levels.


Source link

Different Types of Websites

In the web development world, there are many types of websites. Let’s explore each of them one by one.

  • Static Website
  • Single Page Applications
  • Server-Side Rendering (SSR)
  • Static Site Generator



🎯 Static Website

  • Just be made of HTML pages and could also include CSS and javascript
  • We have to upload HTML pages to CDN to host them on the web and whenever we request those pages in a browser it would return them to us.
  • So for every new page, we made a new request to the server.

static 4.png



✅ Advantages

  • Good for SEO
  • Easy to learn



❌ Disadvantages

  • Hard to update/maintain pages (re-writing a lot of the same code on every page).
  • New request to the server is made for every page which eventually slows down the website.
  • Generally does not contain dynamic data.



🎯 Single Page Application

  • Based on the concept of Client-Side Rendering.
  • A single-page application is an app that works inside a browser.
  • SPAs are structured as a single HTML page that has no preloaded content.
  • Content is loaded via Javascript files for the entire application and housed within a single HTML page.
  • Only a single server request was made for the initial empty HTML page.
  • Everything else (routing, data) is handled by the SPA in the browser.
  • Typical React/ Vue applications come under this category.

image.png



✅ Advantages

  • There is no extra request to the server for other pages which makes the website bit faster.
  • Since SPAs are component-driven so it is easy to update.



❌ Disadvantages

  • It is not good for SEO because of load time & the initial request is for a blank HTML page.



🎯 Server-Side Rendering

  • HTML pages are built on the server-side after every page request.
  • Server gets the data from various sources like databases, aggregates them into template files, and then sends the resulting HTML file back to the browser.
  • PHP or Nodejs with templating engines like EJS, jade, hbs comes under this category.

image.png



✅ Advantages

  • Good for SEO as we get content-rich HTML back from the server on each request.
  • Easy to update



❌ Disadvantages

  • New request to the server is made for every page.
  • Server can take time getting data from various sources & rendering pages that slow down a website a little bit.



🎯 Static Site Generator

  • Process that takes templates, components, and data and then generates static HTML pages based on these things not on the server but at build time before we even deploy the application to the web.
  • Gatsby with React can be used for Static-Site Generator. Other examples are Next.js or Nuxt.js.
  • Inside a Gatsby run a build command on our computer, It takes all of our React components, fetches any data that it needs and combines them, and then generates a static HTML file for each page that we have along with the Javascript bundle too.
  • Then, we just deploy all of those HTML pages & Javascript to a CDN to host, so it becomes a bit like a static site at this point where each page has its own ready-made html file.
  • So, once we deployed this we’d maybe request one of these pages from the browser and the server would send it right back pretty quickly since there is no Server-side rendering involved. It’s all pre-rendered HTML

ssg.png

  • Once we have the page in the browser, the javascript bundle in that HTML page (also generated by gatsby) would kick in and the website would behave much like a Single Page Application.

  • Routing is handled in the browser which makes the website really quick and no extra requests for other pages are sent to the server.

image.png



✅ Advantages

  • Better SEO, because our initial request for a page sends back a content-rich pre-rendered HTML.
  • Easy to update
  • Faster, as no extra request is made to the server.
  • Can handle as many different data sources.



❌ Disadvantages

  • High build time



🎯 Wrap Up!!

That’s all for this article. Thank you for your time!! Let’s connect to learn and grow together.

LinkedIn Twitter Instagram

Buy-me-a-coffee




Source link

Coding a Better World Together with Uncle Bob

If you don’t have the time to watch these lengthy videos on YouTube, this article is for you.

This article was originally published at vtsen.hashnode.dev on Dec 18, 2021.

These are the summary of what I learned from all these “Coding a Better World Together” lessons from Uncle Bob in my own words. I only extract the information that is useful to me.

I added my comment in bold for those that I do not fully agree with him or anything that is significant to me.



Clean Code – Uncle Bob (Lesson 1)


  • By nature, we don’t write clean code. Solving the problem is the main priority. Thus, we need to refactor.



Function

  • Keep function small, do one thing.
  • One thing means you extract until you can can’t do it anymore.
  • Function should be properly named (tells what the function does)
  • Function must be verb.
  • Function should have less than 3 arguments.
  • Don’t pass Boolean into a function for branching purpose.
  • Avoidswitch and if statement. Use polymorphism (open-closed principle).



Side Effects

  • Side effect function changes the state of the system.
  • Use lambda for side effect function that comes with pair (e.g. open a file, and close a file). Pass in processing callback implementation as lambda into a function.
  • Convention to follow – command is a function that returns nothing, should have a side effects. Query is a function that returns value, should NOT have a side effect.
  • Prefer exceptions to returning error codes. Try block should only content one function call which throws the exception. [I made this mistake. Most of my try block contains unnecessary stuff that can be pulled out.]



Others

  • Don’t Repeat Yourself, avoid duplicated code.
  • Software is like science, which cannot be proven correct.



Clean Code – Uncle Bob (Lesson 2)




Comments

  • Comment is to explain the code that you can’t use the code to explain.
  • Comment is a lie, it degrades over time and no one maintains it.
  • Put effort into the code, not the comment.
  • Don’t check it TODO, once checked in, it becomes don’t do [I disagree. Having TODO in code is quite useful. It is developer’s responsibility to implement the TODO]
  • Avoid mandated, journal, noise, position marker, closing brace, attribute (by author) comments.
  • Avoid commented out code
  • Don’t comment code that happens in somewhere else. [I do not fully agree because sometimes we need to do that in oder to clearly explain the intention of the code. I would say avoid this if possible.]



Acceptable Comments

  • Legal comment (copyright)
  • Informative comment (design pattern convention naming that can’t reflect the actual intention, complex regular expression)
  • Amplification (emphasize the importance of why certain code is there)



Variable & Function Naming

  • Should reveal it’s intent
  • The length of the variable name should be proportional to the size of the scope that contains it.
  • Function is opposite, the larger the scope, the smaller the function is.



Code Reviews

  • Time to spend in code reviews should same as amount of time to write the code
  • Pairing in a good alternative than code reviews



Clean Code – Uncle Bob (Lesson 3)




Quality

  • When you release code, you know it works.
  • Ready to deploy (shippable) in each iteration (e.g. 2 weeks iteration)
  • The code should be better over time
  • Fearless competence – don’t afraid to refactor or touch the code. When you touch the code, you break it, then the code is yours. So you avoid touching code. [This sounds so familiar! However, practically this is subjective. Sometimes you do want to minimize the risk with minimum code changes]
  • Expect QA to find nothing.



Stable Productivity

  • You do not get slower (feature production rate does not slow down) when the system gets bigger.



Inexpensive Adaptability

  • Software must be changeable by design. That’s why is it “Soft” ware.
  • The cost of the change should be proportional to the scope of the change



Honest Estimate

  • Always give estimate in a range from the best case to worst case scenario.



Clean Code – Uncle Bob (Lesson 4)


  • No innovations have been made in the software programming for decades. All codes written are still sequence, selection and interaction.
  • But hardware has gone crazy as compared to software.
  • Senior software engineer need to say “NO” when the answer clearly is no. [This is subjective. In software, you do not have definite answer, so you shouldn’t say no in my opinion. “NO” is also a negative word where people often think you’re defensive. I will rephrase it with more convincing bullets]



Test-driven Development (TDD)

  • TDD is discipline and is arbitrary.
  • 3 TDD Rules
    1. You’re not allowed to write any production code until you have first written a test that fails because the production code doesn’t exist
    2. You’re not allowed to write any more tests until all the tests are passed
    3. You can only write the minimum production code that makes the test compile or pass.
  • TDD is like double entry bookkeeping in accounting (e.g. balance sheet)
  • TDD is a significant skill. Learn it well first before you bring into the work.



Clean Code Uncle Bob (Lesson 5)


  • Software architecture evolves, it is not fixed.
  • The goal of software architecture is to minimize the human resource that required to build and maintain the system
  • Writing clean code doesn’t make you slow. You feel slow because of all these disciplines.
  • Software has 2 values:
    1. Value of what it does
    2. Value of its structure (often get ignored)
  • The second value is more important than the first one, because it makes the software flexible. Thus, the cost to change is minimized.
  • Software engineer is responsible to communicate the second value to the stakeholders (who only cares about the requirement), and it is not an easy job.
  • A good architecture allows major decisions to be deferred



Clean Code Uncle Bob (Lesson 6)


  • Fundamental law of any projects you do. Pick any three…
    1. Good (Quality)
    2. Fast (Time to Market, Schedule)
    3. Cheap (Cost Effectiveness, Staff)
    4. Done (Scope)
  • Manage the projects to the best possible outcome (maximize all four qualities above) based on data
  • Agile is iterative development(for small team to do small things) and meant to provide the data (e.g. velocity and burn down charts)
  • The deadline is fixed due to business reason but not the requirement which keep changing
  • Requirements keep changing because the customer does not know what they want until they see it. Thus, the “Waterfall Model” is no longer applicable.
  • Quality is the only way to go fast, do well, go fast. Assuming staff and schedule is fixed, we can only play around with the scope.
  • Never put refactoring into schedule because we’re constantly refactoring. Stakeholder doesn’t care about it.
  • [In my opinion, Agile is a good tool ONLY IF it is “properly” used by the project management. It is often being misused, for example, Garbage in, garbage out.]



Summary

These series of videos are motivating to watch, but a bit too long. I learned something from it but not significant. A lot of stuff is quite common sense, and it could be subjective to the company’s culture.

Personally, I have never done test-driven Development (TDD) before and some minimum of pairing experience. If I have a chance, I would like to give TDD a try.


Source link

How to choose the right CSS properties

CSS might seem very daunting. There are many properties to choose from, and it may sometimes look like it’s not doing what you tell it to. Or, sometimes you find yourself thinking: “There is more than one way to do this in CSS”. In this blog post I’ll cover some of these scenarios, and help you understand how you can justify your CSS decisions.



1. Edge cases

In my opinion, the most important reasoning behind your CSS usage. If you find yourself in a situation where you have multiple CSS solutions, this should be your first thought. Think of scenarios that might not be included in the design, and how your CSS would react to those. Examples of edge cases include:

  • What if the text in this element becomes very long?
  • What if the user uses a smaller device?
  • What if the user zooms in using the browser zoom?

Let’s take for example: how to center a div.

<div class="example">
  <div class="number">1</div>
</div>
.example 
  border-radius: 50%;
  background-color: magenta;
  width: 40px;
  height: 40px;
  box-sizing: border-box;

The .example element is a magenta circle of 40×40. Say we want to place this 1 exactly in the middle of the .example div. You could do this:

.example 
  padding: 11px 16px;

Which works, and looks like this:

Looks perfect! But now watch what happens if it’s not 1, but 11 as a number:

Now the text is not centered in the div anymore! A different approach like Flexbox might be your preferred solution then:

.example 
  display: flex;
  align-items: center;
  justify-content: center;

Thinking outside of the box can help a great deal in deciding which CSS solution is the right fit, because it actually eliminates “wrong” solutions.



2. Browser support

The never-ending struggle of the front-end developer. Browsers all have their unique quirks and features! Or as we developers call them, bugs and inconsistencies. Taking browser support into account can be a deciding factor on which CSS properties to use. The main browsers to take into account are Safari and, to a lesser extent, Internet Explorer 11.

If you want to know more about why these browsers specifically, click here

Safari has a very different approach to development compared to Edge, Chrome or Firefox. They only release new versions every 6 months, and so bugs are always there for at least 6 months. To read a more extensive rant on Safari, I can recommend this article.

Internet Explorer 11 is reaching its end of life very soon, and the whole development world will breathe a sigh of relief when it does. The browser has been ridiculously outdated for a while now, and new awesome features like CSS Grid, or Flexbox, were either not implemented at all, or implemented in their own way. This resulted in many inconsistencies when comparing your page in IE11 to for example Google Chrome.

For example, let’s say you want to change the opacity of an element. You could use either of these two lines:

.element 
  filter: opacity(0.5);
  opacity: 0.5;

The first way, using filter, actually performs better because browsers can use hardware acceleration. However, it’s not supported in IE11. So, if your users use IE11, you might want to avoid using filter. Alternatively, some browsers offer compatibility through the use of prefixes like -webkit-animation instead of animation. Many projects these days use a form of Autoprefixer to automatically do this for you.

Whenever you’re in doubt about what CSS to use, you could check which approach works best in all browsers. Test your solution in Safari or Internet Explorer, or use Caniuse to check if something is supported in all (or enough) browsers. If there is a clear difference, you’ll have your answer.



Maintainability

From this point the reasoning becomes more subjective, and so I’ve stopped numbering them. Whatever floats your boat more.

What if someone has to come back to your HTML/CSS and made some adjustments? Will that person be able to understand what’s going on in the ruleset? Can they easily amend some of the HTML without the rules becoming invalid? Keep in mind, this person could be you! Think of the future when you write your CSS.

For example, let’s say your HTML structure looks like this:

<nav>
  <button>Home</button>
  <button>Options</button>
</nav>

If you want your options button to be aligned to the right within the nav, you could achieve that like this:

nav:first-child + *  
  margin-left: auto;

And that would be completely fine! For now. If a developer comes back to this after a month or two and makes a slight tweak to the HTML, this CSS will not work anymore.
Here’s some HTML tweaking examples that break this CSS rule:

<nav>
  <button>Home</button>
  <button>Blogs</button> <!-- Now this element is targeted -->
  <button>Options</button>
</nav>
<nav>
  <div> <!-- This is now the first child, and it has no sibling -->
    <button>Home</button>
    <button>Options</button>
  <div>
</nav>
<nav>
  <img class="company-logo" src="...">
  <button>Home</button> <!-- Now this element is targeted -->
  <button>Options</button>
</nav>

Furthermore, it is not very easy to read. Instead, you could do this:

<nav>
  <button class="home-button">Home</button>
  <button class="options-button">Options</button>
</nav>
nav .options-button  
  margin-left: auto;

This CSS is much clearer to read (the .options-button in the nav should have space to the left). It is also unaffected if for example a wrapper <div> is added around the buttons, or if more menu items are added before it.



Semantics

This is in my opinion the best way to settle 50/50 questions like: should I use padding or margin? Should the top element have margin-bottom or should the bottom element have margin-top? Let me explain what I mean.

Let’s take as an example a button containing some text.

<button class="example-button">
  <div>Click me!</div>
</button>

You could use either of these rulesets to achieve the same effect:

.example-button 
  padding: 10px;


.example-button div 
  margin: 10px;

Result:

But which of these rules make more sense? Is it more logical that the button should always have 10px of breathing room on the inside, or that the div inside the button always has 10px of breathing room on the outside?

A trick I like to use here is: try to imagine there’s another element in the equation. In this case, maybe the button has an icon before the text. In that case, is it more important that the button has the padding, or that the text has the margin? Then it seems more logical that the button should have padding.

Let’s look at another example:

<h2 class="example-header">Beautiful header</h2>
<p class="example-text">Lovely bit of text</p>

Let’s say we want to add 20px of space between these elements. Do you give the .example-header a margin-bottom? Or the .example-text a margin-top?

If we apply the same trick as before, we can for example imagine another paragraph before .example-text. Would you want the 20px space to be between the two paragraphs, or between the header and the first paragraph? By looking at it this way it makes more sense to add the margin on the bottom of the header.



Less is more

Performance is important. Longer CSS means more bytes. More bytes means longer loading time. It’s not the reasoning I use often, since the differences are often minimal and not as impactful as reducing your JavaScript code, but it’s a valid reason to write margin: 0 3px 6px 1px; instead of spelling out each individual property.



Conclusion

I hope this post will help you either make a decision on which CSS properties to use, or justify a decision that you’ve already made. I now leave it up to you to put these in your personal order of importance. Personally, I love semantics and I find myself often basing my CSS decisions on that rule, after checking for edge cases or browser support. However, I know preferences differ and I want everybody to write their CSS the way they want to. Just, keep this in the back of your mind 😉.


Source link

How to Animate an Emoji with CSS

If you go to the home page of this website, you might find some hidden “easter eggs” around the page. One of which is an emoji that is animated using CSS. 👋 is the emoji. It’s just a waving hand, that doesn’t actually wave. There is no animation, so I wanted to make it move. It’s actually pretty easy!



Step 1: Create HTML

<div class="waving" data-hover="👋">Hi</div>

All I’ve done here is create a simple div with the text, “Hi”. Then I’ve given it 2 HTML attributes, class and data-hover. The contents within data-hover ( 👋 ) is what will be animated.



Step 2: Create CSS

`.waving:before
content: attr(data-hover);

.waving:hover
animation-name: wave-animation;
animation-duration: 3.0s;
animation-iteration-count: infinite;
transform-origin: 70% 70%;

@keyframes wave-animation
0%
transform: rotate( 0.0deg)

10%
transform: rotate(14.0deg)

20%
transform: rotate(-8.0deg)

30%
transform: rotate(14.0deg)

40%
transform: rotate(-4.0deg)

50%
transform: rotate(10.0deg)

60%
transform: rotate( 0.0deg)

100%
transform: rotate( 0.0deg)

`

.waving:before defines the content of which is to be displayed ( 👋 ).

.waving:hover defines what action happens when we hover over that element. In this case we have an animation-name which is defined below in @keyframes wave-animation. We also give it an animation-duration of 3 seconds and tell it to animate infinitely.

@keyframes wave-animation is where we create the actual animation. In this case, I wanted to make the hand wave, so to do this I just want the hand to rotate back and forth. I add different keyframes and tell it to rotate a certain number of degrees in certain intervals. This mimics 👋 actually waving!

You can apply this basic template to any emoji. Be creative! For example, you can try to animate a rocket 🚀 using CSS. Just think of what type of animation you want it to do (possibly translate up and down).

For more articles check out my blog @ anthonydellavecchia.com


Source link

Web Design Layout Best Practices for Medical Professionals in 2022

Introduction
We all know that small changes in your websites can increase or decrease conversion rates. And finding the right marketing campaigns for your healthcare business is an important yet difficult task. Web design should be dynamic because we need to change web design and its features from time to time to beat competitors. Any changes in your websites should ensure the best results for your visitors and Google crawlers.

You need to learn and implement some best web design practices which can help you get more customers and leads and of course conversion rate. The layout of your web page is very much responsible for the conversion rate. So, let’s cover in detail some of the best web design layout practices for your web page or website.

Why Web Design Best Practices Are So Important?
Because users care about web design. Web design best practices always make a positive impact on your audience and increase your brand value. Due to this audience will spend more time on your website and then the bounce rate will be decreased.

Take a look at some facts:-
• Based on visual design, 75% of users judge a company’s credibility. First impressions can last for years.
• Positive initial impressions lead to higher satisfaction. It takes visitors just 50 milliseconds to form a first impression.
• Around 38% of users do not engage with a website that has an unattractive layout and content.

Quality content matters a lot. But quality content with poor web design is not acceptable. The visual representation and website navigation have the biggest influence on user’s initial impressions of your brand. People are naturally drawn to good design and well-designed websites have more conversion rates than poorly designed and optimized ones.

Think about your audience
The first task is that you need to think about your audiences before you engage with your design team or healthcare app development company. What does your targeted audience want from you? Think about what your audience will prefer. Will they prefer a simple, plain, traditional web layout or a relish web design layout?

Create a detailed plan for your target audience and act according to that plan. Once you understand your audience you can move further in the web designing process.

Compressed Images
Everyone loves quality content and it includes quality images too. All the images or info graphics you use for your website should be unique, high quality and eye-catching. But big images with high storage size will reduce page loading speed and make a bad impression among your audience as well as on Google rankings. In order to provide quality content, don’t sacrifice your site speed. Use compressed images and JPEG is the best option because it doesn’t lose its quality after compression.

Better Navigability
Better navigation is one of the important aspects of web design layouts. Navigations elements should be as simple as possible for users to easily navigate and make it easier for users. Take an example of the top healthcare app development company website:-
Big typography is used for navigation.

  1. Higher Functionality of a website design makes things easier to find.

  2. Web design best practices improve your website credibility and brand value.

  3. Boost your sales by making your website mobile responsive.

  4. Always pick a Secure Web Host because small websites are also vulnerable to cyber attacks.

  5. Try to use inbound marketing methodology to increase conversion rates.

Conclusion
Tomorrow the devices we wear in our everyday lives will play a new role in our health. The best website design layout depends on the goal of the website and its content. You need to try different techniques and tools to create the best design. Flexible and mobile-friendly web designs are more preferred by users. A good web design provides a positive experience among your visitors and helps you to beat your competitors.


Source link

Modern Software Engineering [Book Notes]



Notes



What’s Software Engineering

TL;DR: A scientific approach to creating Software. Full of information on how to master learning and handle complexity in our field.

Modern Software Engineering Book

  • Software Engineering applies a scientific approach to finding solutions to problems.

  • Engineering is stuff that works!

  • Software development is the process of discovering and learning, so we need to become experts at learning and handling complexity.

  • Software Engineering practices must allow us to build software faster and better. If not , it is just a waste of time.

  • Software is not a Production problem (physical things with a high cost of replication). Then we need to use different tools for the job such as testability, experiments, continuous delivery remember that our real focus is learning and discovery.

  • Our Aim as software engineers is to create systems with high Stability and High Throughput (Measuring Performance)

Stability = Change Failure Rate + Recover Failure Time
High Throughput = Lead time + Frequency of Deployment



Optimize for Learning

Learning is a fundamental factor in our job as professionals, also key in the discovery process of our systems.

  • Iterative
  • Incremental
  • Empiricism
  • Feedback
  • Experimental

The main idea is to focus on small steps gathering feedback

  • Work in a way that allows us to make mistakes
  • Explore the problem and make experiments controlling the variables
  • We need to learn from previous experiences



Optimize for handling

Edsger Dijkstra said
The art of programming is the art of handling complexity

  • Complexity
  • Cohesion
  • Coupling
  • Separation of concerns
  • Modularity
  • Information hiding and abstraction

The main idea is focus, keep things simple.
Remember that Simple != Easy



Tools to support engineering in Software

  • Testability
  • Deployability
  • Controlling the variables
  • Continuous delivery

One of the main takeaways for me in this chapter was tackling problems from:
Business Vision, Goals > Technical Architecture > Process > Organizational Structure

instead of

Organization Structure> Business Vision, Goals > Technical Architecture > Processes

Conclusion: this book provides valuable insights about Software Engineering and the practices that allow us to work on a Scientific approach.

Dave Farley Youtube
Dave Farley Twitter




Source link

Decorator in Ruby on Rails



– English Version –

Decorators provide a flexible alternative to subclassing for extending functionality. Simple! 😉

There are several ways to implement it, but the easiest for me is using Draper gem.



1. Create Rails app

> rails new decorator-rails



2. Install Draper gem

> bundle add draper

Well, from this moment when we create a controller it will automatically create our decorator file in app/decorator folder.



3. Create user scaffold

> rails g scaffold User first_name last_name

Among other files, the file app/decorators/user_decorator.rb has been created automatically.



4. Add custom method

# app/decorators/user_decorator.rb

class UserDecorator < Draper::Decorator
  delegate_all

  def full_name
    object.first_name + ' ' + object.last_name
  end
end

That allows behavior to be added to an individual object without affecting the behavior of other objects from the same class.



5. Decorate object in controller

# app/controllers/users_controller.rb

def show
  @user = User.find(params[:id]).decorate
end



6. Show it in View

# app/views/users/show.html.erb

First name: <%= @user.first_name %>
Last name: <%= @user.last_name %>
Full name: <%= @user.full_name %>

And now your view logic has been abstracted and organized to where it should be. This will greatly help you to reduce the code in your view files.

Usually it is used with Presenters, but I prefer to do it in another post 😉

🔍 Recommended reading

Thank you for reading 🙏

🌎 https://sergioturpin.es
📷 Instagram
🐦 Twitter
🐙 GitHub



– Versión en Español –

El patrón Decorator nos permite poder encapsular un objeto para que podamos extender su funcionalidad antes de su instanciación, así de simple! 😉

Existen muchas formas de implementarlo, pero una de las más sencillas es hacerlo con la gema Draper.



1. Creamos la app de Rails

> rails new decorator-rails



2. Instalamos la gema Draper

> bundle add draper

Bien, a partir de este momento cuando nosotros creemos un controlador, automáticamente se creará también su decorador en el directorio app/decorator.



3. Creamos el scaffold de usuario

> rails g scaffold User first_name last_name

Además de otros archivos, el fichero app/decorators/user_decorator.rb ha sido creado automáticamente.



4. Añadimos un método personalizado

# app/decorators/user_decorator.rb

class UserDecorator < Draper::Decorator
  delegate_all

  def full_name
    object.first_name + ' ' + object.last_name
  end
end

Esto nos permite agregar comportamiento a un objeto individual sin afectar al comportamiento de otros objetos de la misma clase.



5. Decoramos el objeto en el controlador

# app/controllers/users_controller.rb

def show
  @user = User.find(params[:id]).decorate
end



6. Lo mostramos en la Vista

# app/views/users/show.html.erb

First name: <%= @user.first_name %>
Last name: <%= @user.last_name %>
Full name: <%= @user.full_name %>

Y ahora su lógica de vista se ha abstraído y organizado donde debería estar. Esto le ayudará enormemente a reducir el código en sus archivos de vista.

Normalmente es usado conjuntamente con el patrón Presenters, pero he preferido hacerlo en otro post 😉

🔍 Lecturas recomendadas

Gracias por leer 🙏

🌎 https://sergioturpin.es
📷 Instagram
🐦 Twitter
🐙 GitHub




Source link

2022 Opportunities Tech outlook



Introduction

With 2021 gradually rolling away with just less than 24 hours to go, 2022 is right before us. This year may have been a good year for some in tech, possibly landing a gig, building a cool app or simply advancing knowledge to be able to be a better developer in the field of choice. With 2022 close by, some people may be looking to venture into the tech industry and are wondering: where to start? Where can I fit in? Probably there may be some looking to do something not actually coding related but is still cool and profiting.



Goals

At the end of this tutorial readers will be aware of some opportunities present in the tech industry and will be able to pick a place to fit in come 2022.



What is Tech?

Amazing how one word could mean lots of different things when defined from different perspectives. A simple definition of Tech in relation to it as a career is that tech relates to a field that makes use of tools and set of skills or knowledge geared towards creating products or services that satisfy a particular need.

Would the tech industry be beneficial as a career path? The answer is pretty much a big YES! While tech jobs are really interesting to get into, statistics also show steady increases in demand in the tech sector and well grossing pay for various tech fields. Best tech jobs are projected to pay even more than the average median wage of $34,750. Here’s a list of some tech jobs and their pay gotten from zdnet.com, The 10 fastest-growing salaries by occupation also included:

  • Technical support engineer ($68,651, +8.2%)
  • Cloud engineer ($136,479, +6.3%)
  • Business analyst ($97,633 +5.3%)
  • Web developer ($81,550, +4.9%)
  • Data engineer ($118,621, +4.7%
  • Cybersecurity engineer ($134,340, +4.3%)
  • Data architect ($133,064, +3.2%)



Some fields in the Tech Industry

With tech covering a wide range of skill sets, there are a lot of fields one can get into depending on interest or goal of venturing into tech.



Web Developers

This set of people are concerned with building scalable web applications. These applications may vary in terms of usage. Web development over recent years has been growing more popular and there’s always an increasing demand for people in this field. If you have no problems with learning programming languages or writing codes and have always been fascinated about web pages and wondered how you can make one, well guess you just found your choice field :). Being such a broad field, web development is further divided into two parts, namely: front-end and back-end web development. The former deals with designing the user interface of the website probably in accordance to design specifications while the later deals with developing the applications back-end which may consist of the app’s data management, provide authentication for users and much more. These are primarily things that occur but are not directly visible to the user.



Web Designers

Interested in the web but don’t enjoy writing code? Well, these guys are responsible for everything users see on a site. They design the workflow of websites which are then designed by the developers. These design cover choices of fonts, animations and the application layout.



Software Developers

These guys write and ship large amount of codes which in turn developsp software used on a daily basis by individuals or companies. They develop applications, system softwares, operating systems among others.



Web Page Builders

They develop web applications, but what makes them different from the web developers mentioned earlier? Unlike web developers, these set of people make use of Content Management Systems (such as WordPress) – basically just using pre-existing tools to create a website without having to hard program.



UX / UI designer

UX focuses on the overall feel of a product and how customers interact using the application, while UI is focused on how the product is laid out. This covers the design of the product while maintaining consistency specified by the UX. UI designs can be on web sites, system applications layouts e.t.c



Technical writer

This set of people are concerned with authoring manuals or technical specifications on various topics which will be beneficial to their readers.



Game Engineer

Interested in the field of gaming? Here are some choices you can choose from in tech:

  • Game designer – works on developing the game concept – characters, setting, storyline, levels, animations. Basically the general idea behind the game
  • Game developer – has the technical skills required to turn the game idea into reality, by converting the sketches and storyline into a playable product
  • Game tester – the most fun job of them all – working to test the games thoroughly to uncover potential bugs and give insight on areas where the game can be further improved before being released to the public



project manager

Organizes and manages a team of professionals while taking the job of building a product or service. Make sure team members meet their quotas, resources are well managed and product is shipped timely.



Graphics Designer

Makes use of computer graphics software to create beautiful illustrations, design logos, fliers, UIs among others. A field that’s easy to fall in love with if you have an apt for pretty designs.



3d Modelling and Animations

Concerned with creating character and environmental models for use in animations, games or other purposes. Makes use of animation software to create nice moving motion pictures or animations.



Tech recruiter

Identify potential job candidates for IT positions, reviews and submits these information to hiring managers for consideration.



Cloud Engineer

This set of people comprises of IT professionals responsible for any technological duties associated with cloud computing. These include design, planning, management, maintenance and support.



Cybersecurity engineer

People in this category are concerned with internet security and prevention of cyber crimes. They are sometimes called information security engineers. They identify threats and vulnerabilities in systems and software then use their skills to develop and implement high-tech solutions to defend against hacking, malware and ransomware, insider threats e.t.c



Conclusion

There are a lot of fields in the tech industry which would be a good fit for your choice of skill sets or interest, finding the right one to indulge in is the first step in taking a tech career.


Source link