路上的banq 大哥,我想请教你一个问题啊!就是我现在学Spring框架不说时间长吧,但是也有大概两个多月了,基本上的mvc知识都掌握了,但是现在给我一个项目需求的话,我去进行设计,感觉还是不知道怎么下手去做!虽然我身边的人一再说:当前国内的软件行业都是这样子,只要能用就可以了!不需要什么OO设计啊,什么OOA,OOD的,我经常和他们讨论甚至快吵起来了,我就是想问banq 大哥,像我这种情况,如果还想好好的进行深入的学习的话,应该怎么样去做?您有没有一个从需求到设计,编码,测试的文档和案例啊!以供小弟进行学习啊!小弟不甚感激!

感觉现实世界中只注重系统的框架,这个本人觉得很不重要,但是为什么很多人认为懂多些框架的人才是牛人呢?
其实软件项目中最重要的是业务领域的建模,这个才是最重要的,因为这个才是解决实际问题的部分.
有人说JAVA,ORACLE才能驾驭海量流量,但本人用PHP和MYSQL也没觉得有问题.

语言,框架,数据库这些都是工具,请不要说的那么神.
业务领域OO建模才是项目成功的硬道理.

说的一针见血

J2EE定义了一种开发基于Java的Web方式的C/S应用的规范。但是,它也包含了非Web方式,也就是传统的C/S方式。
J2EE开发平台:符合J2EE规范的开发平台,如:Eclipse等。
J2EE服务器:可以部署运行J2EE服务器端代码的应用服务器,如:IBM WebSphere等。
J2EE 架构:表示J2EE规范允许实现的应用分层及构成各层的元素。说允许实现,是因为它还包含了不属于J2EE但可容纳于J2EE的东西,譬如:JavaScript。
J2EE发行包:在开发J2EE应用时定义一个Enterprise Archive。最终生成的是一个压缩包,用于部署。
J2EE容器:用来分隔和区别不同组件,负责容器内部的通信。
J2EE API:狭义的J2EE就是指这一API集合。分“必需的”和“可选的”两部分。因此,上面的那些东西,要在前面冠以“J2EE”,必须支持必需的J2EE API。
J2EE角色:J2EE之所以能被称之为“企业的”,其中之一是对应用开发做了有史以来最好的分工。J2EE规范定义了六个角色:产品提供者、工具提供者、应用组件提供、应用组装者、部署者及系统管理员。

只想说一句
"中微软毒太深,因为微软已经帮你做了架构的事情,你唯一要做的就是拿来某个软件,按照其说明书做,但是为什么这么做,几乎没有人去研究。"
这句话是有问题的,微软这样做没什么不对,方便了开发人员,将复杂的底层技术与上层业务分隔得很好,由专业的人员开发开发工具,由业务开发人员开发应用。为什么ROR会流行?是因为它提供了一整套的解决方案而不是一堆零件。很多JAVA开发者目的只是开发业务应用,但却被迫去学习太多底层的、不断推陈出新的架构知识,这并不是一件好事。

The good programming needs to meet several criteria:
1. Simple and easy to read
2. easy to extend the new functionality
3. easy to pinpoint error location
4. easy to test
5. excellent performance

from 1 to 4, it should be a normal programmer's basic principle.
The 5 is a little demanded, not that easy.

J2ee provides the distributed applicatin a good development platform
and framework.
All the computer science evolves till now are based on tier or layer theory.
why do we need layer?
Reason:
1. layer makes architecture general and transparent, loosely couple code is easy to trace error due to the small quantity of the functionality needs to be done by programmers.
2. layer makes parallel programming in team, which means each programmer can develop his own part without interfering others.
3. layer can be reused and recombined to make new functionality efficiently

So J2EE was born for big business distribution application.
1.Developers can parallel work in different tier but in real situation, even in Europe, not so many companies are doing that.

2.Developers can concentrate more on business level which means how to realize business requirement relatively ingoring the technique level stuff such as communication acknowledge, multithread issue etc.

As a big web distributed application, you must consider following issues:

1. if it is a real-time application such as stock exchange,how to deal with large volumn request
2. how many different level of logs do we need
3. how to handle exceptions
4. how to test the business functions
5. how to handle multiuser issue

J2EE at least provides you several well-done solutions:

1. The application Server saves you time to realize cluster
which offers you the fault tolerance and the load balance two functions.(if you ever study parallel programming , u know how many codes you need) of coz, you can argue this is a system level parallel solution which is too general and not take in effect in your specific application. I agree but better than none.

2. EJB , the most valuable bean is its stateless session bean which is thread-safe and the application server will pool the beans for you. That is to say , you dont need to worry about the multithread issue and you dont need to consider the memory consume situation for these beans. you will argue Spring is same. Right!! but dont forget
a typical trap to use Spring with your singleton class. you still have multithread issue due to the singleton class can be accessed by each request except you use thread local singleton. Therefore, that adds more task for you to develop. But EJB has side-effect which is too much configuration but X-doclet can solve the problem. it will be headache first time but later on it is just copy and paste.

3. if your client is based on SWING and it needs multiple users, then the EJB stateless session bean is no doubt the first choice.

4.J2EE framework also solves your pain in Authentication and Authorization. if you still code your password and username via a database select statement, then we are talking about different security level. but for the real Business application, JAAS is a rather good choice. Only Configure.


5. J2EE framework provides a super transaction system.
Lots of Business Application need to realize a long transaction which includes a series of function calls. But J2EE lets you configure them easily in the description file to solve your pain in the ass. what is more, due to the different database transaction normally has different internal transaction system,normally developers need to bridge them via a long shit hand made code. you must first well understand each database transaction working mechanism and APIs , then you can code your bridge. Definitely , it is too much overhead.
The XA solves the heterogenious entities transaction problem.
It means a homogenious tansaction can range from JMS to EJB etc.

6.J2EE framework offers you the asynchronous communication tool
JMS which in large saves your time to write such kind of application such as MSN messenger. A traditional way is to allow the client side polling to server all the time via socket.
Then u must handle a lot of shit such as acknowledge, port opening blabla.....

Hibernate is contravertial.
pros
it fill the gaps between relation database and object oriented design. Because oject oriented design has inheritance relationship and composition but relational database only has composition such as one-to-one, one-to-many

it makes SQL-alphabetic able to program persistent layer code.

The code looks more object oriented if the complete design is well object oriented.

cons
It has a long study curve and hard to maintain during teamwork specially working remotely for each team members.
It has extremely bad trade-off: due to its general nature, so it is internal SQL translater makes your HQL a rather cumbersome and low efficient SQL statements, please I use plurial here.
it means you need one statement by hand writing SQL which will be replaced by Hibernate for more than enough SQL statements.
That is rather expensive to call Oracle SQL parser and all other system overheads. we will talk later about DB.
The worse situation is when you modify one thing in database column, never ever forget to change mapping file and pojo. orelse
that will be the catastroph. that is against our principle simplicity which is the overhead of the development. it is not a push but a obstacle.

The good way is DAO pattern. personnally I think what it differs from Hibernate is you did the mapping between db and oo yourself.
So eclipse has a perfect refactor tool. it eases your modification.


Why MVC is good stuff.

1. it makes your application easy to reuse and easy to find error,hardly to have bug.

But most of the junior programmers dont understand what an application is complex.

In fact, an applicaiton can be abstractly viewed as two parts:
business data and business logic

the data is what users input and what we need to show them after internal modification

the logic is how business works to make the business data change upon the user's requirement.


So a hard to maintain application commonly appears to be like this:

your internal datastructures hold some overlapped business data.
For example, your vector has data A,B,C and another hashmap has B,D,E
then vector is to server one interface for example a table and it modifies the data B. but you will easily forget to update B in hashmap too if it is a big application.

Then the typical error : data inconsistent happened.
that is what we scared.

but MVC avoids that or we can say observer pattern avoid that situation.

your business data is concentrated in one layer. so each component in presentation layer will not have this data inconsistent error.

Currently all the java and its derivated framework theoretically is based on IOC, inversion of control pattern.

It saves your time to repeat coding some routine codes you need to do in each application almost and let you more concentrate on your applicaiton specific code which fulfills your business requirement.

As u can see, in java , from Swing,application server ,spring etc,lots of frameworks are built on this concept.

Briefly speaking, this kind of the framework has several features:
1. you have to inherit an build-in interface or several to complete your specific codes in these inherited methods.
2. you dont need to know how these methods are to be invoked by framework.
3. but you did need to know when these methods are invoked and specially you must know the sequence of the invocation among these methods you inherited. That is the key to understand all Java.

More Tier or layers mean better architecture?

Wrong. Three layers are the extreme for the normal application can support.

Too much layers make the contrary effect for simplicity.
Image if you have ten layers, you realizes your loosely couple architecture but you risk a bug-oriented application at the beginning and you also bear a rather big performance loose such asHibernate.
Why?

so now you have ten layers. from layer one, function A calls Func B in layer 2 and etc.... if there is sth wrong at the end of the stack. how could you know which layer is the root of the error?


So the architecture should be flat shape but not smooth.
Everything is double blade sword.

good luck to all java programmers

1. 我们谈论了J2EE,但究竟什么是J2EE?它是规范吗?它是技术吗?它是在什么样的背景下出现的,为了解决什么?

名可名,非常名。不要把j2ee去对应几个孤立的词汇,它既是规范,也是技术。应对企业级业务的复杂度。

2.我们也谈架构?但究竟什么是架构?架构出于什么目的?架构的目标是什么呢?

简言之, 利用架构承载业务设计的复杂度。

3. 我们频繁的使用Struts,但它帮我们解决什么呢?可能有人会说它是MVC的实现,但这不是问题的答案.MVC它又解决了什么呢?

我认为struts解决在异构(脚本结构与对象结构)情况下,输入输出数据对应传递的问题。
顺便说, hibernate在解决在异构(对象结构与关系结构)情况下,输入输出数据对应传递的问题。 异构+映射+IO,是主要问题。

MVC给出的是答案的结构特征,对应着一种解决问题的思路。



youway 说得有道理。

J2EE不但是规范,而且首先是规范,是标准,其次才是技术。

其实,我们所做的构建软件的架构就是框定软件的组织结构,为了让软件功能组件更快更好的找到自己的位置。现在成熟的结构都是分层架构,为什么要分层?目的就是让组件掂量一下自己应该处于哪一个层。

领域建模就是确立各软件功能组件,设计模式就是为了解耦这些软件功能组件,让它们职责明确。

框架就是约束软件功能组件之间的交互。struts也好,hibernate也好,都是在解决两个不同层之间的交互问题。

还好,刚接触J2EE才3天。快速浏览了Tech Youself J2EE in 21 Days.虽然似懂非懂,大致明白了只是个规范和框架,看到banq的详述,很有兴趣。不过项目是已经成型,只是开发MDB。俺还是有希望能快速入手的。
J2SE弄了几个月做纯粹单机上的applet,没事也看了看OO.看到好多问学习的,我觉的Head First - Design Patterns就是非常好的OO入门(不过,感觉和应用到J2EE还有点差距)。
以后多来逛逛,好好学习,天天向上!!!!

J2EE用了2年多了,最近在学习java串口技术,USB通信,打算做一些东西
[该贴被serialeasy于2008-03-05 21:52修改过]