Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8267967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T05:43:09+00:00 2026-06-08T05:43:09+00:00

I got the fruitless task to incorporate some programs my predecessor wrote. One horrible

  • 0

I got the fruitless task to incorporate some programs my predecessor wrote. One horrible mess of unorganized code.

So far I know only about the automatic identation (C-i). So I wonder if you can suggest some tool.

some key problems I’m having:

  • Assignment to the same structure is sparkled through the whole file
  • This is one big file of code – I would like to split it
  • Quite a lot of code produces results that are never used

Update
On the nice looking part I found that the Matlab mode of Emacs can break overlong lines quite reasonable.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T05:43:12+00:00Added an answer on June 8, 2026 at 5:43 am

    Incremental refactoring is the way forward.

    • Pick an m-file that seems reasonably self contained and work out what it’s supposed to do.
    • Create a test for the m-file. This can be as simple as loading in some data from a file, calling the function with that data as an argument, and checking that the result matches the original output (obviously, before you make any changes, the test should pass!)
    • Start making changes to the file. Every so often, run the test to make sure that it still passes. If it doesn’t pass, then you’ve broken something – undo your last set of changes (you are using version control, right?) and try again.
    • Repeat until complete, always starting from the least dependent functions to the most dependent.

    Unfortunately there is no magic bullet. You can rely on the Matlab linter, which will tell you when a variable is never assigned to or used, or when a function is never called, but beyond that you need to tidy the code up a piece at a time, testing it as you go.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got a programm with 2 threads. one thread is writing some stuff into the
Got some code here that isn't working: $(#sidebar ul li:last).each(function(){ $(this).addClass(last); }); Basically I
Got a bug in some legacy code which communicates with a payment terminal. Just
Got a question for some jQuery wizard who might stumble upon this. When I
got some problems. Built an applet that has to be used step-by-step. After each
Got a problem with my add function to my database. The following code hangs
Got a task to make a program that registers animals and the object is
Got a real simple question but can't figure out the solution. Got following code.
Got a weird one. I've managed a bring it down to a very simple
Got a grid with some numeric columns and it's need to implement for each

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.