0

In My last project, Class files are stored in database, and also one custom classloader is written to take those class files from the database and load them. I am not very good the designing the application.

Could anyone help me in figuring out what is the need of storing class files(bytecode) in the database?

Why would it design like that?

Sunny Gupta
  • 6,929
  • 15
  • 52
  • 80
  • 4
    You want us to *guess* why someone designed an app this way? – Ernest Friedman-Hill Dec 29 '11 at 18:04
  • If any architect level person can answer this..Help would be really appreciated – Sunny Gupta Dec 29 '11 at 18:05
  • @FredHaslam I think you didn't get my point. Just to correct you, The objects of class are not stored in database, .class files are stored in DB. – Sunny Gupta Dec 29 '11 at 18:08
  • 2
    Might it have something to do with build/deployment policies? At several places where I have worked, it was relatively easy to submit change requests for database modifications. Building and deploying an application, however, meant many more controls. While the de facto outcome is the same, satisfying internal controls was easier with database changes. Tho, as indicated by @ErnestFriedman-Hill, this is just a guess. – Saish Dec 29 '11 at 18:12
  • @Saish -- that is just evil enough to be true! :) – Ernest Friedman-Hill Dec 29 '11 at 18:13
  • Wow, engineers. You ask for a chair and they design you a blast furnace that only shoots it's owner. – Perception Dec 29 '11 at 18:29

1 Answers1

3

OK, well, here's a wild guess, where doing this might make sense:

Imagine there are a large number of classes available in alternate implementations; i.e., there are ten different versions of some class named Foo, and twenty different versions of Bar. By storing them in the database, along with the conditions under which each is appropriate, it would be easy to fetch the correct version, load it, and use it. There are other ways to architect this sort of thing, but under some circumstances I can imagine this being relatively elegant.

But honestly, my best guess is that it was an over-engineered system designed by somebody who liked to use databases for everything.

Ernest Friedman-Hill
  • 80,601
  • 10
  • 150
  • 186
  • I really liked your guess..Could you just throw some light on the implementation of Classloader if possible? – Sunny Gupta Dec 29 '11 at 18:16
  • 2
    There is a relevant post [here](http://stackoverflow.com/questions/5329685/how-can-i-load-java-class-from-database). – Saish Dec 29 '11 at 18:17