<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mengjia L</title>
    <description>The latest articles on DEV Community by Mengjia L (@mengjia).</description>
    <link>https://dev.to/mengjia</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1373463%2Fa667d9e9-9f87-4086-b7ae-8f7c71fb704c.JPG</url>
      <title>DEV Community: Mengjia L</title>
      <link>https://dev.to/mengjia</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mengjia"/>
    <language>en</language>
    <item>
      <title>Python Interview Questions (WIP)</title>
      <dc:creator>Mengjia L</dc:creator>
      <pubDate>Fri, 13 Sep 2024 16:16:35 +0000</pubDate>
      <link>https://dev.to/mengjia/python-interview-questions-wip-2e8g</link>
      <guid>https://dev.to/mengjia/python-interview-questions-wip-2e8g</guid>
      <description>&lt;p&gt;&lt;strong&gt;Q&lt;/strong&gt;: What is the difference between a function and a method in Python?&lt;br&gt;
&lt;strong&gt;A&lt;/strong&gt;: A function is a standalone block of code that performs a specific task, while a method is a function that is &lt;em&gt;associated with an object&lt;/em&gt; and can access and modify its data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Q&lt;/strong&gt;: What is the difference between the “is” operator and the “==” operator in Python?&lt;br&gt;
&lt;strong&gt;A&lt;/strong&gt;: The “is” operator checks if two objects are the same object, while the “==” operator checks if two objects have the same value.&lt;/p&gt;

&lt;p&gt;References&lt;br&gt;
&lt;a href="https://coderpad.io/interview-questions/python-interview-questions/" rel="noopener noreferrer"&gt;https://coderpad.io/interview-questions/python-interview-questions/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Ruby Design Patterns (WIP)</title>
      <dc:creator>Mengjia L</dc:creator>
      <pubDate>Fri, 09 Aug 2024 21:58:44 +0000</pubDate>
      <link>https://dev.to/mengjia/ruby-design-patterns-wip-5182</link>
      <guid>https://dev.to/mengjia/ruby-design-patterns-wip-5182</guid>
      <description>&lt;p&gt;Model&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Model represents the business layer of the application, responsible for handling business logic, validations, data persistence, and interactions with the database. (&lt;a href="https://www.rubyguides.com/2019/09/rails-patterns-presenter-service/" rel="noopener noreferrer"&gt;source&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Presenters (View)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;There should be no ActiveRecord queries in views (&lt;a href="https://www.rubyguides.com/2019/09/rails-patterns-presenter-service/" rel="noopener noreferrer"&gt;source&lt;/a&gt;).&lt;/li&gt;
&lt;li&gt;It should be separate from the business logic (here's a &lt;a href="https://softwareengineering.stackexchange.com/a/234254/408993" rel="noopener noreferrer"&gt;great explanation&lt;/a&gt; in case you are wondering what business logic means)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Controller&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A controller can be thought of as a middleman between models and views. It makes the model data available to the view, so it can display that data to the user, and it saves or updates user data to the model (&lt;a href="https://guides.rubyonrails.org/action_controller_overview.html" rel="noopener noreferrer"&gt;source&lt;/a&gt;).&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>The Pragmatic Programmer Summary (WIP)</title>
      <dc:creator>Mengjia L</dc:creator>
      <pubDate>Sat, 06 Jul 2024 17:10:52 +0000</pubDate>
      <link>https://dev.to/mengjia/the-pragmatic-programmer-summary-wip-3d3o</link>
      <guid>https://dev.to/mengjia/the-pragmatic-programmer-summary-wip-3d3o</guid>
      <description>&lt;p&gt;I've been reading the book &lt;em&gt;The Pragmatic Programmer&lt;/em&gt; for a while and here's a summary of what I learned from this book.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Care about your craft

&lt;ul&gt;
&lt;li&gt;There is no point in developing software unless you care about doing it well.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Never run on auto-pilot

&lt;ul&gt;
&lt;li&gt;Constantly be thinking, critiquing your work in real time&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;You have agency

&lt;ul&gt;
&lt;li&gt;Make time to study new stuff that look interesting.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Instead of excuses, provide options&lt;/li&gt;

&lt;li&gt;Don't live with broken windows

&lt;ul&gt;
&lt;li&gt;Neglect accelerates the rot faster than any other factor.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Keep an eye on the big picture

&lt;ul&gt;
&lt;li&gt;Constantly review what's happening around you, not just what you personally are doing.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Great software today is often preferable to perfect software tomorrow&lt;/li&gt;

&lt;li&gt;Invest regularly in your knowledge portfolio

&lt;ul&gt;
&lt;li&gt;Learn a new language&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Critically analyze what you read and hear&lt;/li&gt;

&lt;li&gt;It's both what you say and the way you say it

&lt;ul&gt;
&lt;li&gt;The more effective you communicate, the more influential you become.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Build good documentation in

&lt;ul&gt;
&lt;li&gt;It's easy to produce good-looking documentation from the comments in source code, and we recommend adding comments to modules and exported functions to give other developers a leg up when they come to use it.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Good design is easier to change than bad design

&lt;ul&gt;
&lt;li&gt;Decoupling is good because by isolating concerns we make each easier to change.&lt;/li&gt;
&lt;li&gt;Single responsibility principle is useful because a change in requirements is mirrored by a change in just one module.&lt;/li&gt;
&lt;li&gt;Naming is important because good names make code easier to read, and hence make code easier to change.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;DRY -- Don't Repeat Yourself&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;save you from having to rewrite logic&lt;/li&gt;
&lt;li&gt;prevent you from having to rewrite code when you have to make changes &lt;/li&gt;
&lt;li&gt;avoid human error as you will only be modifying one piece&lt;/li&gt;
&lt;li&gt;make code easier to read&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Make a point of reading other people's source code and documentation, either informally or during code reviews. What you're trying to do is foster an environment where it's easier to find and reuse existing stuff than to write it yourself.&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>Ruby dry-monads</title>
      <dc:creator>Mengjia L</dc:creator>
      <pubDate>Wed, 27 Mar 2024 23:24:56 +0000</pubDate>
      <link>https://dev.to/mengjia/ruby-dry-monads-e14</link>
      <guid>https://dev.to/mengjia/ruby-dry-monads-e14</guid>
      <description>&lt;ul&gt;
&lt;li&gt;🤔 What is the use case for dry-monads?&lt;/li&gt;
&lt;li&gt;😀 return either Success or Failure from some operation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;From the &lt;code&gt;dry-monads&lt;/code&gt; &lt;a href="https://dry-rb.org/gems/dry-monads/1.6/"&gt;doc&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Monads provide an elegant way of handling errors, exceptions and chaining functions so that the code is much more understandable and has all the error handling without all the &lt;code&gt;if&lt;/code&gt;s and &lt;code&gt;else&lt;/code&gt;s&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;user = User.find_by(id: params[:id])

if user
  address = user.address
end

if address
  city = address.city
end

if city
  state = city.state
end

if state
  state_name = state.name
end

user_state = state_name || "No state"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After using dry-monads ✨&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;def find_user(user_id)
  user = User.find_by(id: user_id)

  if user
    Success(user)
  else
    Failure(:user_not_found)
  end
end

def find_address(address_id)
  address = Address.find_by(id: address_id)

  if address
    Success(address)
  else
    Failure(:address_not_found)
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This style of programming is called 🚃 Oriented Programming ( Railway Oriented Programming) - More info &lt;a href="https://fsharpforfunandprofit.com/rop/"&gt;here&lt;/a&gt;!&lt;/p&gt;

</description>
      <category>ruby</category>
    </item>
    <item>
      <title>Code Reviews</title>
      <dc:creator>Mengjia L</dc:creator>
      <pubDate>Fri, 22 Mar 2024 00:42:05 +0000</pubDate>
      <link>https://dev.to/mengjia/reflections-on-code-reviews-2ko4</link>
      <guid>https://dev.to/mengjia/reflections-on-code-reviews-2ko4</guid>
      <description>&lt;p&gt;Looking back on my two-year journey as a software engineer, one of the areas where I experienced most growth is code review 🔍. I knew next to nothing about code reviews when I started my current job in 2022. Thanks to my supportive team members and online resources, I’ve adopted a personal mantra on code review: &lt;strong&gt;I Choose the Intent to Learn&lt;/strong&gt; 🌻&lt;/p&gt;

&lt;p&gt;One of the biggest challenges I faced during my early days is my own insecurity. When I was assigned as a reviewer, I would think to myself I don’t really think I have anything useful to add because I am still new to everything! I’d have the urge to automatically approve when the pull request creator is a senior engineer, since I believed that I had nothing to comment on a PR of a senior developer. &lt;/p&gt;

&lt;p&gt;During a one-on-one meeting with my manager, I shared my feelings about code reviews and he kindly pointed out that I don’t need to provide constructive feedback for every pull request, and it is absolutely okay for me to ask clarifying questions if I don’t understand a particular line of the code 💛&lt;/p&gt;

&lt;p&gt;It was then that I realized that my intention was a bit off when code reviewing. I had the intention of trying my best to spot any potential flaw and therefore providing a &lt;em&gt;useful&lt;/em&gt; review. However, code reviewing is not limited to a one-directional activity where one side purely gives and the other side purely receives. It can be a two-directional activity if you set the intention to learn while you review others’ code.&lt;/p&gt;

&lt;p&gt;This mindset shift drastically reduced my anxiety around code reviews and also taught me the power of our mindset and intention ✨. When I choose the intent to learn, I also find it easier to give constructive feedback since my mind is open and calm.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the code doing?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;do you have the right background info?&lt;/li&gt;
&lt;li&gt;do you fully understand why this code is needed?&lt;/li&gt;
&lt;li&gt;do you understand how this code fits into the project?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Frame your mind
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;how experienced are you with the codebase/language?&lt;/li&gt;
&lt;li&gt;are you going to be using this code in the future?&lt;/li&gt;
&lt;li&gt;have you written code similar to this?&lt;/li&gt;
&lt;li&gt;what is the experience level of the author?&lt;/li&gt;
&lt;li&gt;what is your relationship with the author?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Test the code
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;does the code generate warnings/errors?&lt;/li&gt;
&lt;li&gt;does the code take longer than normal to build/run?&lt;/li&gt;
&lt;li&gt;do the changes require any additional setup steps?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Inspect the code
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;are correct naming conventions followed?&lt;/li&gt;
&lt;li&gt;does the code follow DRY principles?&lt;/li&gt;
&lt;li&gt;are new files/folders named appropriately?&lt;/li&gt;
&lt;li&gt;does the code have error handling?&lt;/li&gt;
&lt;li&gt;is the code written in a similar style to other code in the project?&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Compile your review
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;beware of bikeshedding&lt;/li&gt;
&lt;li&gt;be respectful&lt;/li&gt;
&lt;li&gt;be specific and descriptive&lt;/li&gt;
&lt;li&gt;be open to follow-ups&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’ll keep updating this post as I move along in my career 😊&lt;/p&gt;

&lt;p&gt;Resources for Code Reviews:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://google.github.io/eng-practices/review/reviewer/" rel="noopener noreferrer"&gt;Google Code Review Guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt; &lt;a href="https://www.pluralsight.com/courses/code-review-best-practices?clickid=1VrwKWXCoxyPWtuSoX3spRgcUkHUTCTtRWvCXc0&amp;amp;irgwc=1&amp;amp;mpid=27795&amp;amp;aid=7010a000001xAKZAA2&amp;amp;utm_medium=digital_affiliate&amp;amp;utm_campaign=27795&amp;amp;utm_source=impactradius" rel="noopener noreferrer"&gt;Code Review: Best Practices -- Course&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>codereview</category>
      <category>backenddevelopment</category>
    </item>
  </channel>
</rss>
