views:

211

answers:

4

Hi, i am developing a framework for creating efficient applications in all sizes. Applications consist of modules (application is a module too) and performance is important for me. I know there are existing frameworks for modularization etc. but i needed to implement my own. Although i overthought about performance of individual modules and optimized them, communication between objects (and between threads) is something i cant decide how to implement. Here are the some options i considered:

  • NIO Pipes
  • Events (registering listeners)
  • Transaction queues in application context

My question is, Which one of these is better for avoiding bottlenecks and locks? Or is there any alternative you can advise?

+2  A: 

There are WAY too many variables. The only way to know will be to code your messaging system in a way that's plugable so that you can write it in different ways and measure as you code.

Pity you've thrown out using frameworks, most would be significantly faster, more complete and more usable than anything you could possibly write yourself. Whoever came up with that requirement should be confronted and possibly fired.

Bill K
and more complex and cumbersome :) i just need a simple mechanism
Deniz Acay
Although I understand your reluctance to learn a framework that seems to have a lot of features, I've always found that when I didn't think I needed the features of a framework like this it's because I hadn't spent as much time understanding the problem as the framework implementors--eventually you'll have to implement those features in your own framework.
Bill K
+1  A: 
i am developing a framework for creating efficient applications in all sizes

To give a very general advice I would suggest you dive into the source code of jboss to get an impression how things are made when they are supposed to work (maybe the oldest version you can get, as a starting point)

stacker
+3  A: 

My only advise would be don't go that way. As Bill K already said, most implementations would be significantly faster and more complete. Even more important is that there are excellent resources to achieve what you are trying to do: OSGi for example which has Eclipse and Glassfish v3 under its belt.

Personally I implemented something similar to your description, loading plugins at runtime without needing to restart the container. It was a nightmare to maintain and debug. And more important, while it was relatively easy for me to implement new modules (after all, I designed the thing), it was very difficult to program to. I ended up learning a lot about classloaders, but that was it.

Cesar
+1 - for first sentence. ESPECIALLY since you have to ask a question like this in the first place!!!
Stephen C
+1 same did I, that was the reason to point out working examples where things are arlready done.
stacker
@stacker - we don't even know if the OP is asking about web stuff, so how do we know which examples are relevant?
Stephen C
@Stephen C- i dont want to have a lot of features because i will be using the basic ones- implementing my own is faster than learning existing frameworks- i implement just the features i needand most important of all, how could i supposed to learn if i dont ask???
Deniz Acay
@dacay - "implementing my own is faster than learning existing frameworks" - seriously, no, it's not. There's sometime's a case for reinventing the wheel - but if you're going to build a good/usable wheel it's a good idea to be pretty familiar with wheels in general and the benefits and drawbacks offered by other wheel-maker's various wheels.
Nate
A: 

If this is a project that is intended to lead to production-quality code, I strongly advise you not implement your own framework.

Firstly, it is apparent that you don't really know enough about what your application requires of a framework, or the various technologies that you can use to implement such a framework. Do not underestimate your lack of knowledge, and the risks of undertaking a project where you don't know what you are doing when you start out.

Second, your motivation for implementing your own framework is wrong. If you find an existing framework too big and complicated for your needs, either choose a simpler framework or just learn the subset that you need to do your job ... and ignore the rest.

Third, it is a lot of work designing and building even a half-decent framework. That is probably time you should be spending building your actual application. Sure it is fun, but your boss is probably more interested in results.

Fourth, don't underestimate the intrinsic advantages of using a framework that lots of other people use; e.g. a community to ask questions of (like on SO), a community to improve the framework, employable people with the framework on their CVs.

Finally, by implementing your own framework you are most likely creating a lot of extra future maintenance work for team / company. You get it wrong and your colleagues will be cursing you up and down the corridors for the next 10 years. Even if you get the framework 100% right, someone in your organisation still has to maintain it for the lifetime of the applications that depend on it.

Stephen C
im a student actually. framework i developed is an api for implementing servers that will focus on one job. i know lall about http implementations and cdns. i already wrote almost all of it. after reading what you wrote i decided to use osgi for modularization. my server is using channels and selectors for reading requests then pass them to http interpreter as a selection key. when server generates response it is wrote back to the client. i couldnt find a way to send response back but it looks like when response is ready. it looks like all i had to do was setting keys op to write. thnx
Deniz Acay
Not everybody who programs has a boss, or doesn't see "fun" as a valid reason to do things.
Bart van Heukelom
@Bart - the OP is clearly not doing this for fun. He may or may not have a boss at this point, but he certainly has to consider the consequences of doing something that may derail his project. In this case, the consequence could be that he fails his course. Besides, as a student he also should be learning to think with the mindset of a professional developer / manager. Finally, he DID ask for advice on alternatives, and "use an existing framework" is the best alternative.
Stephen C
But you did not know what he was before you posted your answer ;)
Bart van Heukelom
I didn't know, but it was a fair assumption. The kind of person who would build a brand new framework "for fun" would not ask such a naive question.
Stephen C