Is it possible to generate Django Model from UML - django-models

is there any way to create Django Models from a given UML drawing (e.g. in diagrams.net).
Since I am still new to Django I would like to learn best practices on how to generate models in the most efficient ways.
Thanks inadvance!

Related

Catel + EntityFramework

I'm just a starter and asking a simple question.. Just need a direction where to move.
Can someone explain in very few words the process of application development using WPF+MVVM pattern (using Catel) with database created with Entity Framework.
1. I create models (Code First) and generate database
2. I create View models via Catel base classes
3. I create Views with WPF
The question is: how to connect database with Catel View Models? Where to load DBContext and entities? Should I create repositories? Or maybe it's needed to create separate Models?
Is there a common way or maybe example of a small WPF application which uses database to store data?
Sorry if my question is slightly heretic - simply can't sort all the terms and approaches into a single system which I will follow during app creation...
Though there are technical discussions in the field what is best way, there are two commonly used scenarios:
1) Using repositories (Catel does support implementations of repositories for both EF5 and EF6)
2) Use a service that will handle the functions and call that in the view model like any other service.

Model Structure for Zend Framework

I am new to Zend Framework and currently struggling with the implementation of Model. Actually, what I want is as follows:
I have two tables (am using MySQL):
Musicians(id, name)
Albums(id, musician_id, album_name)
Now, I want to design the model, so that I can create an efficient join query in there.
I have tried many things, but am unclear about various things. For example, currently I have created a Table class (which extends Zend_Db_Table_Abstract), a model class and a model_mapper class. I am not sure, what code to put in which file and how actually I am going to call the model functions (containing the query result) in the action function in controller.
Any help is highly appreciated.
There is no single answer to this question. The best code to put in each class is based on the application logic your requirements call for.
There are methodologies to guide object-oriented design:
GRASP
SOLID
Domain-Driven Design
This free e-book has an introduction to DDD: Domain-Driven Design Quickly

Why use Doctrine instead of CakePHP's standard database ORM?

I've about to start work on a new web project using CakePHP 2.2, having mostly worked with Zend Framework 1 previously.
On first look, I really like the way CakePHP handles models and the underlying database tables, especially with regard to getting one-to-many and many-to-many relationships setup quickly with the minimum of fuss. It seems, quite frankly, a breath of fresh air compared to how I used to do things in Zend Framework.
However, over the last few years whilst using Zend Framework, I had looked at using Doctrine to provide the model relationships that ZF was rather clumsy at doing. Doctrine looked to me to be very powerful and flexible.
So now I am wondering, before I get too deep into my new CakePHP project, should I still consider using Doctrine with my new choice of framework? What advantages and disadvantages does Doctrine bring to the table (no pun intended!) compared to CakePHP's built-in ORM and database functionality?
CakePHP works best if used as a whole. In your specific case though you can use Doctrine instead of Cake's ORM if you like but you will lose lot of features of cake. For eg. the FormHelper does lot of things "magically" like guessing proper input type for fields etc. using the model's schema, automatically showing error message below appropriate fields in forms when validation fails, etc.
As you commented you don't have much experience with Doctrine either so I would suggest sticking to CakePHP's ORM and look for option only if you find it inadequate for your needs.
If you have already worked with Doctrine and CakePHP's ORM, you can decide based on the main reasons to change:
What will give you more productivity?
What will give you more maintainability?
What will give you less learning curve?
Personally, I would choose Doctrine, based on the fact that it is really specific to one problem.

Data Access in ASP.NET MVC 3

What's the recommended way of creating a Data Access layer in real-life ASP.NET MVC applications? Is it EF? Ef Code First? NHibernate? Any other idea?
Thank you & regards
There is no recommend way.
I prefer EF Code First for doing this because
the Sourcecode is very clean and easy to read
It is easy to simple change the connectionstring and generate a new database if not already exists
easy to migrate your Database if your Model has changed (no need to recreate the Database) using EntityFramework.SqlMigrations
if your Database already exists you can use the Entity Framework Power Tools to generate the Models and Database context from your existing Database
It all depends of your need:
NHibernate is a more mature ORM with a big community
Entity Framework is now getting very well supported and you can find also great information (check Julie Lerman blog)
Both support code generation from database.
Code first: allows you to create your database schema from your domain models. This is great if you don't want to bother with database. NHibernate can do it also.
To help you decide which way to use Entity Framework
Source
There are many other great ORM:
Subsonic
Stackoverflow's ORM Dapper if performance is an important criteria there is a small benchmark on the site
If you're partial to the MSFT tooling and wanting to be "modern", then EF Code First is probably the place to start. One example worth perusing: https://github.com/NuGet/NuGetGallery .
I like to use Model First because it allows me the most freedom to design and implement in my opinion. It also makes it very easy to change the database design.
There is none, stackoverflow is full of people who have gone down the various routes, so you can get help no matter which choice you make.
Best advice, try doing a few small exploratory webs using a couple of approaches which seem to stand out.
The MVC gurus (the people who wrote MVC) at MS all seem to use Entity Framework at the moment. having said that you can use any ORM (or really any data access tech you want) as MVC doesnt actually specify anything at all about the way you access data
Try LINQ, most MVC products I see make use of LINQ.

Business Logics of projects under MVVM in WPF?

I am developing an application in WPF using the MVVM pattern. If I have Student as a data model, for example, where could I add the business logic like adding new Students, deleting Students and updating Student info, calculating marks and so on?
Does all the business logics come under the model or the viewmodel?
If it is in the model how can we do that? Any example code please? I need full code for an example!
Business logic should be part of of your model, as all of that code should be reusable across different technology platforms. For example, you may want to reuse your models across a web site in ASP.NET MVC, and a desktop application in WPF, so it wouldn't make sense to have business logic in your view models.
View models should contain presentation logic which is specific to that particular application instance.
As for example code, this will be specific to the domain that you are modelling, so you would have to ask a more specific question about what you are trying to model.
I suggest you read PRISM documentation on this subject: Chapter 5: Implementing the MVVM Pattern.
Even if you don't plan to use PRISM, the article is very well written and details the pattern in Microsoft's technology terms.
I would trust very little of what Microsoft has to say on Patterns as their articles are often dated, or modified to support their own proprietary frameworks or products. Also I've found MS thoughts/approaches contradictory within their different teams and also within the generally accepted approach in software.
Not all of it is good and not all of it is bad basically.
To answer your question. I'd use a Service for Business Logic. I'd instantiate a reference to it in the ViewModel and I would not put any logic in either the ViewModel or the Model that did not have anything to do with their role. ie Presentation logic is okay dependingon what it is, it might be best placed in the ViewModel as it is highly tied to the View in question. Same goes for the model.
Keeping in mind these roles you will have a scaleable and testable application.

Resources