{"id":4944,"date":"2014-03-30T17:10:00","date_gmt":"2014-03-30T17:10:00","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/whats-the-most-efficient-way-to-organize-a-lot-of-methods-collection-of-common-programming-errors\/"},"modified":"2014-03-30T17:10:00","modified_gmt":"2014-03-30T17:10:00","slug":"whats-the-most-efficient-way-to-organize-a-lot-of-methods-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/30\/whats-the-most-efficient-way-to-organize-a-lot-of-methods-collection-of-common-programming-errors\/","title":{"rendered":"What&#39;s the most efficient way to organize a lot of methods?-Collection of common programming errors"},"content":{"rendered":"<p>I am making a mock-java langue, which has a lot of methods. I would group similar methods together and put them in their own class, but <em>all<\/em> of the methods need to extend a class that deals with how to interrupt data. What is the most efficient way, in terms of <strong>runtime performance<\/strong>, to organize them?<\/p>\n<p>Right now it is just a bunch of methods in one class (<code>ListOfMethods<\/code>) called with a special method with if-else statements to find the right method, like:<\/p>\n<pre><code>public void methods(String name, String param) throws NumberFormatException, InterruptedException {\n    if (name.equals(\"systemexit\")) SystemExit(param);\n    else if (name.equals(\"sleep\")) sleep(param);\n}\npublic void SystemExit(String param)\n{\n    int exit=(int)Double.parseDouble(param);\n    System.exit(exit);\n}\npublic void sleep(String param) throws NumberFormatException, InterruptedException\n{\n    Thread.sleep((long)Double.parseDouble(param));\n}\n<\/code><\/pre>\n<p>I am not trying to change this format, just how the methods are organized. I want to group them into classes, like math and strings, but I am wondering the best way to do this?<\/p>\n<ol>\n<li><code>ListOfMethods<\/code> could extend each class. The problem is that Java does not support multiple inheritance, so class 1 would extend class 2 which would extend class 4, etc.<\/li>\n<li><code>ListOfMethods<\/code> could import each class. The problem with this is that they all need to extend a super class. Is that inefficient?<\/li>\n<li>Placing them into different classes and making the methods static (very similar to the previous one).<\/li>\n<li>Simply leaving it as is.<\/li>\n<\/ol>\n<p>I am open to other suggestions &#8211; I want to make it as efficient as possible. Thanks in advance.<\/p>\n<p>Note: there will be hundreds of instances of this class running at once &#8211; this is just a short example of the actual problem &#8211; so I would really not want to waste memory.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am making a mock-java langue, which has a lot of methods. I would group similar methods together and put them in their own class, but all of the methods need to extend a class that deals with how to interrupt data. What is the most efficient way, in terms of runtime performance, to organize [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4944","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4944","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=4944"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/4944\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=4944"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=4944"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=4944"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}