●请申请链接的朋友帮我也做好链接!本站转载他站文章将会注明来源,如果发现未注明或者出处有误,请联系我修改。
●小日本看清楚:钓鱼岛从来就是中国的领土!

骇人听闻的装修工程

[晴 2009/06/30 09:47 | by xeric ]
惊闻国家自然科学基金委员会办公室装修耗资巨大,不太相信,
有人发出链接,于是进入查看:
http://www.mof.gov.cn/mof/...
不看不知道,一看吓一跳,110个亿装修个办公楼!
惊骇之余,我打算细细计算一下这笔用黄金堆起来的装修究竟是什么样子的一个规模,
我特意搜索了一下,金茂大厦的造价的50亿!注意,是造价。
环球金融中心虽然才高出那么一点点,造价却不菲,高达72亿。
不过比起中国的某楼建设,我觉得他们择个良辰吉日自己倒塌掉进黄浦江算了。
110个亿啊!你以为是110万啊?
真的是想告诉世界中国有钱了,还是想告诉世界中国彻底废了?
110个亿,国内有那么多的公益事业,绿化,治沙,治水要去做,装修个大楼?不装修会死么?
我们按商品房的价格来算,一般一套100平米的房子,做个精装修,大约是20万。
我们为了提高中国对外形象,给他翻翻,可以说100平米40万装修费用,所有的设备都是顶级的了,。
当然建筑公司是高档的,没100平米额外白送10万,算50万吧。
110亿可以装修220万平方!可能还没意识到这个规模,那这样吧,金茂大厦一共88层,总面积是29万平米。
这下子有概念了吧,差不多9栋金茂大厦,我f**k这些勾结的动物!
国库那么充裕,干嘛不拿点出来给贫困的人,干嘛不把社会保障体系做做好,
干嘛让老百姓眼睁睁得看那些一天比一天贵,一天比一天容易倒塌的房子,无所适从?
Tags:

Talking from Grails service layer

[阴 2009/04/13 09:51 | by xeric ]
One day, some friend ask me, why grails so looks like the rails, but there's a service layer in this framework.
It's a common question asked by buddy from rails framework.
I'm confused also when just got stating in grails.
I decide to talk about this topic in article, I think most of the idea is just came from myself, may be it's not alright, I just hope it can resolve some confuse and question from newer.
The most different between grails and rails, I think it's focus on grails is domain-Driven, this is came from some special area such as UML and BA. Programmers always not care about the UML and BA in most project. but they are always received some information about domain, entity, model, role, behavior, wow, it's so much nouns, hard to understand, no problem. I talk about them just since they are relative with the DDD.
Some buddies from rails framework is familiar with rich model object, right? That's important concept in rails model layer, we are always like witting model-related logic in model, it's different from java or ejb, an anemia model object language, But are you confused when you see thousands lines of code in the models? Are you feeling why it so far to get ending of the code when you have read the model's code for 1 hour?
Grails choose an standpoint between grails and ejb model, they choose DDD.
It's so familiar with the rails framework when you just get starting with grails, model properties, model constraints and model mapping such as belongsTo and hasMany.
But when you want to add some business logic, problem came out.
Where to add logic? In rails user opinion, coding in domain model is conversion, but why there's a service layer in grails, if we write logic into service layer, how to explain the constraints and validation in domain objects?
It looks like some important  concept in UML, domain-entity-role-behavior.
Example: in a pet store. We have three domain, store, pets, customers.
store has-may pets, customer can buy pets and also has-many pets.
the constraints is pets can not have no store but can null in owner(Customer) object.
the pets' price can not little than zero.
The customer must have non-null name and they must have enough money to buy pets.
the constraints is the meta information of domain, so this logic add to domain class.
when this domain get a instance in back-end, we can call them entity. entity can be described with the relation between each others, and entity has validation them self.
exclude entity concept, the customer, pets and store are also roles, why?
They have behavior, customer have behavior to buy, to pay and to complain.
The pets can shout, and the store can publish pet information.
Ok, where to put behavior code? Not controller layer, not domain layer or not script SRC in grails also. just in the service layer.
More advantage? Yes, service layer can inject into everywhere in the grails framework, so ,if someone want to reuse logic in other place, go ahead.
Service layer can be as an open service API, in web service.
Example, store and customer must login when store want to publish information and customer want buy pet, It's the same logic when auth them, username + password [+ verification code].
You can just write a LoginService in application and inject into store and customer domain(controller) to use.
And when you just want to open a auth API for user from another system, you can use this service as an open API(webservice).
After all, we have some idea when we choosing where to put the different logic, right?
After all, believe and trust DRY concept when you use this Agile Web Framework, that's the most important you must to remember!
Tags: , ,
come from: http://almaer.com/blog/mod...

This is a good thread talking about the service layer,
It's a challenge in enterprise application when you use pure Rich model object.
It's always not like in the book, when you in the middle phase of a project.

Because, there's only hundreds lines of code in the book or in a "simple blog" project, but always thousands lines of code at least in "ERP" project.

I'll talk about the service layer of grails in the next article in my blog.

this is one of my Reference article.
Tags:

Block And Closure, Ruby VS Groovy

[晴 2009/04/09 14:34 | by xeric ]
问题从一个Groovy迭代开始:
def a = 1..9
a.each{
 println it
}

这种简单的迭代work的很完美,但我想改一下需求,只打印等于4的数字
def a = 1..9
a.each{
 if(it == 4){
   println it
 }
}

似乎也正常,但是,其实这边打印了4之后的迭代就没必要执行了,如果是ruby,我会这么做

(1..9).each do i
 if i == 4
   puts i
   break
 end
end

而groovy就不行了,break是不能写入到一个闭包内的
原因也不难发现,groovy的底层是java支持的,那么实现each不用看源码不妨先猜测一下:
each是list的一个meta method,接受一个闭包作为参数。
内部用invoke的方式去把闭包调用起来。
所以这个代码更像是一个封装好的代码块的反射调用,而非逻辑集成,
ruby能工作原因可能是底层中,作为一个闭包并不是简单的block.call或者invoke,
而是编译器已经将其识别为执行流程的一部分,或者说,闭包并没有把逻辑封闭在本身内。
ruby执行码是原始底层支持的
groovy则最终还是java的执行码,这种推断也不是空穴来风,不妨看看一个包含闭包的groovy class编译后的状态:
XXX.class
XXX$_closure1.class
也就是说,闭包也不过是个类而已,因此其中不能添加break来控制调用者本身的流程也可想而知了。
而对于一个block,也就是普通的控制流程{}包起来的流程,比如if else这些包起来的,
则是原生的block,
这点和ruby有着极大的不同,个人认为也影响了程序员的一些第一直觉判断。
而且,如果迭代并不能有效被控制(当然不是绝对,比如continue可以通过return来实现)
那么迭代本身的价值就有所损失,不过真要把闭包trade as block来的话,那groovy底层真的要大手术了。
所以暂时(甚至永远),groovyer必须要把block和closure分分仔细,也不要随便搞乌龙写法出来,
举个例子,试图对一个迭代进行有效选择并返回,恐怕是永远做不到的,安心的for..in吧。

有人说groovy的closure更像是lambda,我觉得挺有道理的,当然,我只了解as和js的lambda,
其他的并不是很了解,我记得Martin Fowler有个介绍closure的文章里面确实也把js的lambda归为js脚本的closure,当然,这个不扯了,概念而已,关键是,要明白怎么用,为什么会这样。

有个很不错的文章,链一下:
http://blog.csdn.net/hax/a...
Tags: , ,

Grails clean

[阴 2009/03/19 21:26 | by xeric ]
标题是个很简单的东西,问题却由下面这段既不提示groovy代码出错行又不具体告知问题的root cause的欠揍的错误信息引起的。

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'transactionManager': Cannot resolve reference to be
an 'sessionFactory' while setting bean property 'sessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error c
reating bean with name 'sessionFactory': Invocation of init method failed; nested exception is org.hibernate.MappingException

引起这个问题的可能性很多,逛了几个国外的maillist,
主要集中在
1:同一个domain class中定义了两个domain definition
2:有个domain class是abstract的
3:你的数据库有了点小问题,重启下数据库试试

好了,我把代码检查了100遍啊100遍,没发现错误也没发现上述问题,
数据库重启了100遍啊100遍,当然,夸张了点,不过我想说的是,就算1000遍也许也没用,
当然,如果你找到代码错误了,那就抽自己吧。

我没抽自己,在万分无奈下,我想起了zend framework和ROR开发时的一个小细节:
马上检查是否grails有clean命令,发现果然有,执行之,重启,问题解决,

郁闷,不是第一次了,每个框架都要搞点缓存的事情出来调戏下我。。。。

以后要首选clean。
Tags:
The single-table inheritance mechanism failed to locate the subclass: ......
......
基本上,十之八九就是有个字段被命名为type了,type属于ActiveRecord保留的属性,还是别用了。
最简单的办法,字段改名吧,改不了名,那这个英文也许能帮你:
This error is raised because the column 'type' is reserved for storing the class in case of inheritance. Please rename this column if you didn't intend it to be used for storing the inheritance class or overwrite Site.inheritance_column to use another column for that information.
让你去修改这个属性,挑个另外一个字段来存储继承信息,还是看需求了。
如果你的表是从其他应用迁移过来,并且很多地方都依赖这个名字,那建议还是修改这个属性,否则,改名吧。。。
Tags: ,
分页: 1/68 第一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] 下页 最后页 [ 显示模式: 摘要 | 列表 ]