Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Duplicated Code from Pontos and Sana #463

Open
ybensacq opened this issue Sep 25, 2024 · 10 comments
Open

Refactor Duplicated Code from Pontos and Sana #463

ybensacq opened this issue Sep 25, 2024 · 10 comments
Labels
ODHack8 Only dust 8

Comments

@ybensacq
Copy link
Contributor

In this repository, we duplicated parts of the Pontos project to build Sana.
As a result, there are many instances of duplicated code that could potentially be refactored to improve maintainability, readability, and reduce redundancy.

It would be great if we could refactor these duplicated areas to streamline the codebase.
If anyone is interested in helping with this refactoring, contributions are welcome!

Feel free to share your thoughts and suggestions on how to best approach this.

@ybensacq ybensacq added the ODHack8 Only dust 8 label Sep 25, 2024
@ShantelPeters
Copy link
Contributor

Hi @ybensacq please i will like to work on this issue?

@aji70
Copy link

aji70 commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

i'm a solidity and cairo smart contract developer with over 2 years experience and believe i have the skill set for the task

@dlaciport
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have experience in Rust, especially in refactoring task.

How I plan on tackling this issue

I will refactor and also try to improve code coverage for these refactored paths to ensure the code still work well after refactoring. I will also keep communicating with the maintainer to ensure the refactoring is heading the right direction.

@GideonBature
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a Software Engineer with experience in writing Rust, Typescript and Cairo. I participated in the last ODHack (ODHack 7.0) and I was assign a task to refactor the deployment script written in typescript of a project written in cairo, which I completed and was merged.

How I plan on tackling this issue

I will first of go through the code based to understand the structure, next I will start looking at each of the files one after the other, taking note of each of the functions and their use-case.

Will afterwards start by removing redundant code, if there are any, then move forward to unify and merge the functions with the same functionality, finally will do a thorough testing to be sure that my changes is not breaking anything.

@abdegenius
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a skilled fullstack developer with a wealth of experience in both frontend and backend JavaScript as well as my knowledge of Rustlang, With a solid foundation in testing,I have mastered frameworks like Mocha, Chai, and Jest to ensure robust, reliable code in every project. In addition to traditional web development, I have a strong background in blockchain technology, with hands-on experience in Solidity for Ethereum-based smart contracts. Moreover, I have delved into the emerging world of StarkNet, working with Cairo, a cutting-edge language tailored for STARKs, making them a versatile developer capable of bridging both traditional and decentralized web applications.

How I plan on tackling this issue

  1. Identify Duplicated Code
    Automated Code Analysis: Utilize static code analysis tools like SonarQube, CodeClimate, or ESLint to scan the repository for duplicate code and other code smells.
    Manual Review: Conduct a manual audit of the codebase, focusing on high-traffic modules that were likely copied from Pontos to Sana. Pay attention to commonly used utilities, helper functions, and components.

  2. Classify Duplicates
    Group Similar Duplicates: Once identified, categorize the duplicated code into buckets based on functionality. For instance:
    Utility functions (e.g., logging, data transformations)
    API handling and middleware
    UI components (if applicable)
    Check for Project-Specific Differences: Some duplications may have small variations to meet specific project needs. Carefully evaluate these differences to ensure that refactoring doesn’t break functionality.

  3. Create Shared Modules or Libraries
    Abstract Common Logic: Refactor the duplicated code into reusable modules, functions, or classes that can be shared between projects (Pontos and Sana). This can be done by:
    Creating a shared internal library or package.
    Moving common code into a utils or common directory within the repository.
    Extracting reusable UI components or hooks for frontend projects (if relevant).
    Use Dependency Management: If Pontos and Sana will continue to evolve separately but share similar functionality, consider abstracting the duplicated code into a separate repository, versioning it, and including it as a dependency in both projects.

  4. Incremental Refactoring
    Prioritize Critical Sections: Start refactoring critical or frequently changed areas of the codebase to minimize the risk of introducing new bugs.
    Test-Driven Refactoring: Ensure robust test coverage with unit, integration, and end-to-end tests before making changes. Refactor one part at a time, running tests at every step to maintain stability.
    Gradual Refactoring: Aim for incremental improvements. You don’t need to refactor everything at once. Start with small, manageable changes that won’t disrupt ongoing development.

  5. Collaborate on Contributions
    Create a Refactoring Plan: Document the refactoring plan, detailing what needs to be refactored, who will be responsible, and timelines for completion.
    Open Contributions to the Team: Encourage team members to take ownership of specific parts of the code that they’re familiar with. Use GitHub issues or a project board to track refactoring tasks and assign them accordingly.
    Code Reviews and Pair Programming: Conduct code reviews and encourage pair programming to ensure consistency in refactoring approaches and best practices across the codebase.

  6. Documentation
    Update Documentation: As refactoring progresses, update the documentation to reflect the new structure of the codebase, ensuring that future developers understand where the shared components are and how they should be used.
    Maintain Changelogs: If new shared libraries or modules are created, maintain changelogs to track updates and potential breaking changes.

  7. Feedback and Continuous Improvement
    Team Feedback: Regularly solicit feedback from the team on the refactoring process. Encourage developers to suggest improvements and report issues related to maintainability or readability.
    Continuous Refactoring: Make refactoring a part of the team's ongoing process to ensure that the codebase remains clean and efficient over time.
    By following this approach, the repository will become more maintainable and easier to work with, while also reducing technical debt over time. The goal is to create a streamlined, well-organized codebase that both current and future developers can easily navigate and contribute to.

@Luluameh
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have experience in Rust and refactoring code for improved maintainability. I’ve worked on similar projects, reducing code duplication and improving readability without compromising functionality.

How I plan on tackling this issue

I’d start by identifying and comparing the duplicated code between Pontos and Sana. I’d refactor shared logic into reusable components or modules, ensuring the refactor improves maintainability and reduces redundancy while maintaining code clarity.

@jimenezz22
Copy link

thanks @ybensacq for assigning me the issue, I will start working asap

@jimenezz22
Copy link

@ybensacq I am not going to continue with this issue because I am having a lot of problems getting the local environment up and I need to move forward with other issues of this odhack, my apologies for the case

@jimenezz22 jimenezz22 removed their assignment Oct 5, 2024
@od-hunter
Copy link

Hi @ybensacq , can I get this done please since no one is assigned? I’m ready to work please.

@SoarinSkySagar
Copy link

SoarinSkySagar commented Nov 6, 2024

gm @ybensacq, I would like to work on this. I am providing my background, approach and ETA. kindly assign this issue to me so I can start working on it.

My background:

I'm a full stack engineer and smart contracts developer with extensive experience in typescript, rust and cairo.

My approach:

I will create a new crate for common code which can be shared by pontos and sana. Then, I will start analyzing the two crates to identify the common code, which I will then refactor into the shared crate, and use it in pontos and sana crates by importing them.

ETA: 3 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ODHack8 Only dust 8
Projects
None yet
Development

No branches or pull requests

10 participants