Git Product home page Git Product logo

puddles's Introduction

Hi 👋,   I'm Shelton

Twitter Badge

About Me

I'm a experienced software engineer, mostly foused on the front-end area✨. Previousely, I was worked for ❤️ThoughtWorks❤️ as a consultant, right now worked for a start up company as full-stack engineer👨🏻‍💻.

Joined Github since 2015 🐳

I still remember, it's the second year of my University, I hit the github website for the first time. I created my first account brainysoon,and then the sheltonsuen I'm currently using.

Daily work

  • 🛠   I’m currently working with TS, React&AntDesign, Java&Spring, Python&Pandas, etc.
  • 🚀   I’m currently interesting in compiler, especially babel.
  • 💬   Ask me about anything here! I am happy to help.
  • 📫   How to reach me: [email protected].

Languages and Tools:

typescript babel javascript

puddles's People

Contributors

sheltonsuen avatar

Forkers

fossabot

puddles's Issues

Encapsulate Collection

Problem: A class contains a collection field and a simple getter and setter for working with the collection.

Solution: Make the getter-returned value read-only and create methods for adding/deleting elements of the collection.

Replace Type Code with State/Strategy

Problem: You have a coded type that affects behavior but you cannot use subclasses to get rid of it.

Solution: Replace type code with a state object. If it is necessary to replace a field value with type code, another state object is "plugged in".

Lazy Class

Signs and Symptoms

Understanding and maintaining classes always costs time and money. So if a class doesn't do enough to earn your attention, it should be deleted.

Replace Parameter with Method Call

Problem:
Calling a query method and passing its results as the parameters of another method, while that method could call the query directly.

Solution:
Instead of passing the value through a parameter, try placing a query call inside the method body.

Primitive Obsession

Signs and Symptoms

  • Use of primitives instead of small objects for simple tasks (such as currency, ranges, special strings for phone numbers, etc.)

  • Use of constants for coding information (such as a constant USER_ADMIN_ROLE = 1 for referring to users with administrator rights.)

  • Use of string constants as field names for use in data arrays.

Preserve Whole Object

Problem:
You get several values from an object and then pass them as parameters to a method.

Solution:
Instead, try passing the whole object.

Change Value to Reference

Problem: So you have many identical instances of a single class that you need to replace with a single object.

Solution: Convert the identical objects to a single reference object.

Comments

Signs and Symptoms

A method is filled with explanatory comments.

Large Class

Signs and Symptoms

A class contains many fields/methods/lines of code.

Duplicate Code

Signs and Symptoms

Two code fragments look almost identical.

Replace Type Code with Class

Problem: A class has a field that contains type code. The values of this type are not used in operator conditions and do not affect the behavior of the program.

Solution: Create a new class and use its objects instead of the type code values.

Replace Array with Object

Problem: You have an array that contains various types of data.

Solution: Replace the array with an object that will have separate fields for each element.

Replace Magic Number with Symbolic Constant

Problem: Your code uses a number that has a certain meaning to it.

Solution: Replace this number with a constant that has a human-readable name explaining the meaning of the number.

Self Encapsulate Field

Problem

You use direct access to private fields inside a class.

Solution

Create a getter and setter for the field, and use only them for accessing the field.

Replace Data Value with Object

Problem: A class (or group of classes) contains a data field. The field has its own behavior and associated data.

Solution: Create a new class, place the old field and its behavior in the class, and store the object of the class in the original class.

Remove Setting Method

Problem:
The value of a field should be set only when it is created, and not change at any time after that.

Solution:
So remove methods that set the field's value.

Hide Method

Problem:
A method is not used by other classes or is used only inside its own class hierarchy.

Solution:
Make the method private or protected.

Change Value to Reference

Problem: So you have many identical instances of a single class that you need to replace with a single object.

Solution: Convert the identical objects to a single reference object.

Replace Exception with Test

Problem

You throw an exception in a place where a simple test would do the job?

Solution

Replace the exception with a condition test.

Duplicate Observed Data

Problem: Is domain data stored in classes responsible for the GUI?

Solution: Then it is a good idea to separate the data into separate classes, ensuring connection and synchronization between the domain class and the GUI.

Replace Constructor with Factory Method

Problem:
You have a complex constructor that does something more than just setting parameter values in object fields.

Solution:
Create a factory method and use it to replace constructor calls.

Long Method

Signs and Symptoms

A method contains too many lines of code. Generally, any method longer than ten lines should make you start asking questions.

Replace Type Code with Subclasses

Problem: You have a coded type that directly affects program behavior (values of this field trigger various code in conditionals).

Solution: Create subclasses for each value of the coded type. Then extract the relevant behaviors from the original class to these subclasses. Replace the control flow code with polymorphism.

Replace Parameter with Explicit Methods

Problem:
A method is split into parts, each of which is run depending on the value of a parameter.

Solution:
Extract the individual parts of the method into their own methods and call them instead of the original method.

Encapsulate Field

Problem: You have a public field.

Solution: Make the field private and create access methods for it.

Replace Subclass with Fields

Problem: You have subclasses differing only in their (constant-returning) methods.

Solution: Replace the methods with fields in the parent class and delete the subclasses.

Data Clumps

Signs and Symptoms

Sometimes different parts of the code contain identical groups of variables (such as parameters for connecting to a database). These clumps should be turned into their own classes.

Change Unidirectional Association to Bidirectional

Problem: You have two classes that each need to use the features of the other, but the association between them is only unidirectional.

Solution: Add the missing association to the class that needs it.

Change Reference to Value

Problem: You have a reference object that is too small and infrequently changed to justify managing its life cycle.

Solution: Turn it into a value object.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.