ServiceFramework icon indicating copy to clipboard operation
ServiceFramework copied to clipboard

目前此框架的用户群有哪些人?进来讨论讨论^_^

Open fengkuok opened this issue 13 years ago • 4 comments

简单看了一下,很多想法确实很好。但是从一个Java EE出身的程序员角度来讲,恐怕很难接受很多约定,命名规则等等(方法名、字段小写且下划线分割,采用yml配置)。

但是如果是rails出身(实际上可能大部分rails程序员都是从其他语言转过来的)转Java EE项目来讲,可能比较顺手。

另外,从纯语言的角度来讲,Ruby相比Java,真是太简洁了。

fengkuok avatar Oct 09 '12 10:10 fengkuok

作为一个J2EE程序员表示很喜欢这种没有xml的框架

zhouzhenhao avatar Oct 10 '12 07:10 zhouzhenhao

1 命名规则仅仅限定于 Model。对数据库和模型一开始进行约定是有好处的。省却了很多代码。 2 yml 配置文件相对来说比较简单。而ServiceFramework的配置也很少。所以这个基本不会造成什么影响。 3 ruby 和java 适用范围不同。我不多说。Ruby 和 PHP 是更加接近的,都适合做'client'.举个例子,以新浪微薄为例, t.sina.com 网站页面是用php做的。后端真实的数据处理,包括队列等都是java实现的。这个时候php和普通的app 没有区别。

allwefantasy avatar Oct 10 '12 08:10 allwefantasy

其实语言的角度来看,什么样的语言看是什么人写的,ruby也可以写出复杂的东西来。 在于自己使用,其实个人任务,一个简单的事情,用一步做完和分N个复杂的步骤来做,还不然用简单的。

追求简洁是很有必要的,我之前也写过PHP框架,现在的项目用java找到这里,感觉和之前的设计思路极为相似。 就使用了,allwefantasy 写的东西很帅,java能写成这样,真的是不错的了。。。。

真没搞懂java这么多个框架,有人真的去读过框架里面的代码么,是否是真的有必要写成那样?

xinqiyang avatar Oct 23 '12 02:10 xinqiyang

如果你去看看 develop 分支里面,里面会有更多精彩 --------华丽的分割线-----------------

开发分支已经添加了对mongodb的支持。你基本可以使用相同的语法操作mongodb. 贴一端基本的测试代码:



public class Person extends Document {
    static {
        storeIn("persons");
        hasMany("addresses", new Options(map(
                Options.n_kclass, Address.class,
                Options.n_foreignKey, "person_id"
        )));

        hasOne("idcard", new Options(map(
                Options.n_kclass, IdCard.class,
                Options.n_foreignKey, "person_id"
        )));
    }

    public Association addresses() {
        throw new AutoGeneration();
    }

    public Association idcard() {
        throw new AutoGeneration();
    }


    private String name;
    private Integer bodyLength;


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getBodyLength() {
        return bodyLength;
    }

    public void setBodyLength(Integer bodyLength) {
        this.bodyLength = bodyLength;
    }
}


public class PersonTest extends IocTest {

    @Test
    public void testDocumentHasManyAssociation() {
        Person person = Person.create(map(
                "_id", 100,
                "name", "google",
                "bodyLength", 10
        ));

        person.addresses().build(map("_id", 77, "location", "天国的世界")).save();
        person = Person.findById(100);
        List<Address> addresses = person.addresses().filter().fetch();
        Assert.assertTrue(addresses.size() == 1);

        Address address = addresses.get(0);
        Person person1 = address.person().filter().singleFetch();
        Assert.assertTrue(person1.getName().equals(person.getName()));

        person.remove();

        for (Address address1 : addresses) {
            address1.remove();
        }


    }

    @Test
    public void testDocumentEnhancer() {

        Assert.assertTrue(Person.collectionName().equals("persons"));
        Assert.assertTrue(Address.collectionName().equals("addresses"));
        Assert.assertTrue(Document.collectionName() == null);
        Assert.assertTrue(Document.collection() == null);

        Person person = new Person();
        person.setName("我是天才");
        Assert.assertTrue("我是天才".equals(person.getName()));

        person = Person.create(map(
                "_id", 100,
                "name", "google",
                "bodyLength", 10
        ));
        person.save();

        Person personFound = Person.findById(100);
        Assert.assertTrue(personFound != null);
        Assert.assertTrue(personFound.attributes().get("name").equals("google"));

        List<Person> personList = Person.where(map("name", "google")).fetch();
        Assert.assertTrue(personList.size() == 1);
        Assert.assertTrue(personList.get(0).getName().equals("google"));


        personList = Person.select(list("name")).where(map("name", "google")).fetch();
        Assert.assertTrue(personList.size() == 1);
        Assert.assertTrue(personList.get(0).attributes().toMap().size() == 2);

        personFound.remove();
        personFound = Person.findById(100);
        Assert.assertTrue(personFound == null);


    }
}

可以看到,对mongodb的操作也可以非常简介的。而且你似乎很难区分出底层存储是mongodb还是mysql.

因为Java语法缺乏简介性。比如普通语言语言建一个hash,可以这样:

query = {"name"=>"google"}

查询可以直接这样:

dbCollection.find( {"name"=>"google"})

如果是java 的话

dbCollection.find( new BasicDBObject("name","google"));

如果再复杂点的查询,就可以去死掉了。

allwefantasy avatar Oct 23 '12 03:10 allwefantasy