Skip to content

Identify 'code smell' and refactor. #35

@v0dro

Description

@v0dro

Rubex was written in a bit of hurry, so parts of the code base are quite messy. Identify these smelly parts and refactor them with better design. Refer to Martin Fowler's Refactoring Ruby book for reference. Here's a rough list based on basic parameters like a method/class doing too many things or being too long. Feel free to add your own.

  • Statement::Alias#analyse_statement.
    This method is using an if-else approach for detecting function pointers. Ideally we should use a new class for denoting function pointers for arguments (like this commit: ff00ff8)

  • Expression::MethodCall#analyse_statement

Method is too long and does too many things in 30 lines of code :O

  • Expression::Name#analyse_statement

Too long and does too many things.

  • analyse_statement in Expression classes

    The analyse_statement method should only analyse statements and make sense of their types
    and generate symbol table entries etc. Currently methods of this name exist in Expression
    classes as well. This should go so that there is a clear demarcation between statements and
    expressions. Don't just rechristen to analyse_expression. Let there be some value to it.

  • Separate classes into their own files as per ruby-style-guide.

  • Expression::CommandCall#generate_evaluation_code
    Method is too long and does too many things. Too many conditionals.

  • ElementRef#analyse_statement

  • ElementRef#generate_evaluation_code

  • Expression::StringLit class
    Class trying to be both a Ruby string and C string. Segregate.

  • Refactor temp allocation mechanism. Current mechanism requires too much work on part of programmer.

  • Refactor code generation. Current mechanism relies on the c_code construct which does not convey meaning properly and does too many things in one method in many cases.

  • Unify Statement::ArgumentList and Expression::ArgList. There should be only one class for dealing with argument lists.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions