Eclipse: A Simple Framework to Keep Your Projects Clean and Reusable

Writing clean and reusable code can be a big challenge, especially on Roblox. Organizing your project assets is another beast altogether. For the past few months, I’ve been putting together a personal game framework to help combat such isssues, and now, I am proud to unveil my framework to the community. Introducing Eclipse!


This framework encourages you to write reusable code and organize projects without adding too much fluff or changing how you program. Eclipse’s minimalistic approach to this problem means you, the developer, are free to have your game function as you wish while still enjoying the benefits of the framework.

FEATURES


  • Easily maintain an organized code base.
  • Organize as much or as little as you want. Eclipse will only nudge you in the right direction.
  • Modularized approach allows versatility in code style. You can write functional projects or go full-on OOP and get the same benefits.
  • Shared variables allow you to reuse code and assets on the client and server when needed, or lock certain items to the server.
  • Designed to be as non-intrusive as possible, unlike some frameworks.

SETUP


Right now, the only way to get Eclipse is to install the plugin: Eclipse Framework - Roblox
However, I fully intend to dump everything onto github and make a model version of Eclipse too.

After installing the plugin, simply click this button and the framework will be added to your project:
lol this is for guests u knob
(Warning: If you already have the Eclipse framework setup in your game, everything you have will be overwritten. Luckily, the plugin has undo support.)

Once Eclipse is added, you’ll notice a few new folders and scripts in the explorer:

Stop2

These are all part of the Eclipse framework. MainGame is where you will store almost everything in your project, Libraries is where you’ll keep your code, and Remotes is where you will keep your RemoteEvents and RemoteFunctions.

Notice how the meat of your project will be in ReplicatedStorage. This is to encourage code reusability across the client and server. There’s a separate folder in ServerStorage for stuff the client shouldn’t be able to see:
Stop2

Adding Code:


To start adding your code, first consider that Eclipse expects everything to be modularized. Therefore, 100% of your code will be in module scripts. This modularized approach will, again, give you incentive to make your code reusable and easy to access.

You can just store all your code in the Libraries folder, but I recommend adding sub-folders to act as containers for everything. To get an idea of what I mean, here’s what my production project looks like right now:

Stop2
Hopefully you now have an idea of how organization works in the Eclipse framework. Folders are everything! You can nest the folders however much you want, but the more you have, the more writing you will need to do when requiring your modules (Unless you use the “GenericFunctions” code, which I’ll cover later).

All code that needs to run immediately should be in the client or server Init folder. Typically, such code is the backbone of your project and you’ll probably be requiring the other modules with it.

Do not delete the Init folders or Eclipse will break. Oof!

Remote Functions and Events:


Just like your code in the Libraries folder, remotes can be nested in the Remotes folder:

Stop2
Now, I tried to make Eclipse as non-intrusive as possible, but you are going to have to follow a specific pattern to get your remotes working.

That’s because of how Eclipse works. Behind the scenes, Eclipse will search through your Libraries folder on the server to see if it can find any corresponding code for each remote event or function. Then, whenever the remote is fired, it will execute that code. Eclipse is set up this way so you can have all your code in one place.

To link your remote code to the actual remote object, simply name the module the code is in “YourRemoteNameEvent” for RemoteEvents or “YourRemoteNameInvoke” for RemoteFunctions. Then, make sure the function to be called is named “OnServerEvent” for RemoteEvents or “OnServerInvoke” for RemoteFunctions. For example:

local YourRemoteEvent = {}

YourRemoteEvent.OnServerEvent = function()
   print("Hello there")
end

return YourRemoteEvent

You can change “Server” to “Client” for events being handled on the client.

Shared Variables


Another feature Eclipse has is “shared variables.” These are variables you find yourself reusing a lot. They can be referenced on the client, server, or both. You declare these variables in the SharedVariables module, located in the Libraries folder. By keeping these variables in one place, you force yourself to use the same name for everything and save time constantly making references to the same things. Shared variables just make programming across multiple scripts less painful.

By default, the SharedVariables module gives you direct access to everything in the MainGame folder. It also has a few services and references I constantly reuse in it. You can preview it here:

To make programming in Eclipse easier, I recommend keeping and maintaining this module.

Edit: I know the shared variables module is incomplete. I’ll finish adding references later. In the meantime, you can do that yourself :wink:

Generic Functions


The only fluff in Eclipse is the auto-inclusion of a “Generic Functions” library. This library basically contains code I reuse a lot across projects. It can be removed from Eclipse pretty easily, but the “FindFirstDescendant” function is actually really useful for Eclipse as you can simply use it to find the first module with a corresponding name instead of typing all your subfolders when programming. If you don’t want the Generic Functions library, I at least suggest implementing some way to quickly grab your modules!

Conclusion
That’s Eclipse! Let me know if you have any questions.

28 Likes

This looks cool, but I think the name would make people think of the popular Java/CPP IDE Eclipse, by Oracle. I’d consider changing it to something else. Not really that important, but just a suggestion.

9 Likes

Great stuff! ill use this on my next project! :grinning: :grinning:
I also like the FindFirstDescendant method!

2 Likes

Wow this is amazing! Definitely going to use for my future projects!

2 Likes

Wait; if the meat of your project is in Replicated Storage, Doesn’t that mean exploiters will have acess to steal scripts and assets normally safe-gaurded on the server?

Yep. That is why there’s also a folder in ServerStorage for all your server-sided code.

1 Like