Some refactoring needed? - Printable Version +- Cuberite Forum (https://forum.cuberite.org) +-- Forum: Cuberite (https://forum.cuberite.org/forum-4.html) +--- Forum: Development (https://forum.cuberite.org/forum-13.html) +--- Thread: Some refactoring needed? (/thread-242.html) |
Some refactoring needed? - Lapayo - 12-26-2011 Hey, I´m new to this project and because of this I had to read into many codes. But what i realized was, that there is often code just copied and pasted instead of creating reusable code / using the benefits of oop. To give an example, I worked on the water and lava simulator and made them easier. Code reduced by about 40% and as an additional benefit the simulator is much easier to config because it´s not so "hardcoded". You can look at it in R108 ( http://code.google.com/p/mc-server/source/detail?r=108 ) What do you mean? Or am I to reusable / oop fanatic? RE: Some refactoring needed? - mtilden - 12-26-2011 The reason I use copy paste is when I don't have a clear idea of what the final outcome will be, and that's only when working with other people's concepts. For example, I'm copy pasting some code in my local version of mcserver because there's slight changes and I'm not sure what the final outcome will be of what variables would be passed through to the function because I don't know 100% of all the other factors pertaining to it. Top-down design only works when you're starting something new, it's not possible to know every single outcome and parameter when it's pre-existing until you know it, and then you can set it up exactly. Hope this makes sense. RE: Some refactoring needed? - FakeTruth - 12-26-2011 Agreed, but you pointed to something extreme :p I don't think you'll find much more of this in the source RE: Some refactoring needed? - Lapayo - 12-26-2011 Yes, luckily this is something very extreme But this was the code which I wasn´t able to leave untouched I think one thing could be the cWindow::Clicked but I´m not sure yet. Looks like there is the crafting part implemented in some different windows. I think I will look into this in the next time But fixing and adding has a higher priority RE: Some refactoring needed? - FakeTruth - 12-26-2011 With your change I got this warning cfluidsimulator.cpp(76): warning C4355: 'this' : used in base member initializer list http://stackoverflow.com/questions/3509447/initialize-a-reference-warning-c4355-this-used-in-base-member-initializer It's dangerous. You can fix it by simply removing the initialization of m_Data from the intializer, and putting it in the constructor. Just use m_Data(0) in the intializer. RE: Some refactoring needed? - Lapayo - 12-26-2011 Ohh, My fault I will commit this in the next few minutes when the cobblestone thing is tested RE: Some refactoring needed? - Lapayo - 12-26-2011 Ohh I found something big for refactoring The mobsystem was very C & P ´ed http://code.google.com/p/mc-server/source/detail?r=112 Removed bPassiveAggressive Replaced by cPassiveAggressiveMonster Parentclass state Aggressive is replaced by AggressiveMonster and state Passive is replaced by PassiveMonster This makes it much for easy to add new states because not every behavior is hardcoded in the cMonster class The cause for looking at it was a bug which caused mobs to follow player in creative mode. I would had to implement this code for every partially aggressive mob. Now I only had to change the AggressiveMob class RE: Some refactoring needed? - AsianBusinessman - 12-26-2011 I guessing a lot of you are using VC2010? I say this because every revision I find the makefile to be out of date. Could you fellas update the makefile when you add new files before you commit them? Oh, and Merry Christmas! RE: Some refactoring needed? - mtilden - 12-26-2011 I've done a lot with linux but I'm not on the up and up with makefiles and all. Is there a specific way to auto generic the makefile? If so I could keep it up each revision as I have a Linux VM always ready to go. RE: Some refactoring needed? - mtilden - 12-26-2011 Nevermind that, edited the makefile, fixed up some files and got it to compile on Ubuntu 11. Download page on google code has binary packages for linux and windows and SVN revision 121 is set up to compile with either. I don't own any macs and don't plan to, so sorry about that. |