creating an n tier .net application - n-tier-architecture

I have three projects which are class libraries. One is the Biz layer with the entity classes in it, another is the Data STore Layer with the DAL classes in it and finally both these projects hve been referenced in the controller project which co-ordinated the entire use case. The controller class lib project is referenced in the windows form project.
I have created interfaces that are implemented by the Entity classes the Biz tier. I am using these interfaces in the winform project to store a reference of the entity class objects that are returned by various functions into the windows form. I am doing this since i do not want to directly reference the Biz logic layed in the windows form project and I need a loosely coupled solution. Only the Contoller classlib is referenced in the windows form. However when i use the interface to store the object reference of the entity class in the windows form project it gives a compile error asking me to reference the Biz logic layer project. The interface has the same declarations as the actual entity class.
How should i solve this problem.

Related

Use DAC from One Customization Project in Another Customization Project in Acumatica

I have two customization projects in Acumatica 2020R2. I need to reference a DAC from one of the customization projects in another customization project. The Acumatica instance that has one of the customization projects may or may not have both customization projects published.
For instance, a graph in one customization project may need to reference the VendorRebate DAC that was created in another customization project to check if a customer has a rebate for a particular inventory item before setting a price.
Is there a way to reference the DAC without having to include the DAC in both customization projects?
Also, is there a way to check if the Acumatica instance has the necessary customization project published (besides using conditional compilation)?
Is there a way to reference the DAC without having to include the DAC in both customization projects?
First of all, if the projects are ever going to be published together you should never create duplicate DAC definitions. This can lead to crashes at runtime. It doesn't matter that the DAC are identical. Acumatica Framework will not be able to resolve the conflicts properly in all scenarios for identical types. This typically results in error can't cast object of type X to object of type Y.
Also, is there a way to check if the Acumatica instance has the necessary customization project published (besides using conditional compilation)?
Use the 'Validate Customization Project' action from the customization Publish menu. Unless you dynamically load DLL references you won't be able to publish.
The Acumatica instance that has one of the customization projects may or may not have both customization projects published.
To reference a type it has to be published, otherwise it is just inaccessible.
The most common option for your use case is to create a third customization project/DLL that contains the shared types.
Otherwise you can try to conditionally deactivate feature using the IsActive property.
DAC IsActive reference:
https://help-2021r1.acumatica.com/Help?ScreenId=ShowWiki&pageid=9ca4cca5-a46c-4dda-af09-8cb8b0793c34
Graph IsActive reference:
https://help-2021r1.acumatica.com/Help?ScreenId=ShowWiki&pageid=cd70b408-b389-4bd8-8502-3d9c12b11112
To load the referenced type only when it exists you would need to put it in a DLL first and load this DLL dynamically at runtime: https://stackoverflow.com/a/18362459/7376238

C++ access to QML component properties without creating component instances

Consider the following QML example component defined in Test.qml
Item {
readonly property string name: "Test Component"
}
and I'm loading the component from C++
QQmlComponent comp(&engine, QUrl("file:/path/to/Test.qml"));
Is there any way to access the read only property name without creating an instance by calling comp.create(...)? I'm asking this because I want to use QML components to realize dynamic plugins. Each plugin should represent a project dependent interface. These "plugin" QML Files will be contained in a single folder and should be presented as a listing of the plugin/component names. The user should than be able to select which one of the plugins should be used (and instantiated by the application).
Since each "plugin" will also affect how the underlying C++ model is built and only one "plugin" should be instantiated at the same time, creating an instance of each just to get the name would introduce a significant overhead which I'm trying to avoid.
Unfortunately the property(...) method of QQmlComponent only refers to the component object but not to the properties of the underlying QML component. Is there any way to read default/read only properties without creating an instance?
Suggestions for alternative solutions are welcome as well.

How do I handle injectables in tests for an Aurelia CLI project using Karma and Jasmine

My project is organized as such:
App (Creates a router from 'aurelia-router')
Wizard (Routed component; injects the router - along with some custom stuff)
Steps (Collection of Step objects in Wizard; each Step has a reference to parent Wizard)
Questions (Collection of Question objects in Step; each Question has a reference to parent Step and parent Wizard)
I'm trying to test functionality of a Question object, but in order to do so I need a Step and a Wizard so references don't break.
Creating an instance of the Wizard object means I need to provide the injectables to the constructor, which is easy for my custom stuff and nice for providing a mock. But creating the Router from scratch seems wrong and I don't know how or if it's even possible to get Router from App within a test.
So, my question is, is there a way to get access to my instance of Router within App from a test so I can provide it to my Wizard constructor? Or am I barking up the wrong tree?

Zend Framework, Architecture with Doctrine

im learning Zend Framework (3) ... I installed Doctrine because i do not want to write sql queries to learn all other stuff faster....
First Question:
So know i configured a factory that loads me the doctrine entity manager to my Controllers (with DI).
So its really simple to get my entities to my controller ... e.g in my Project Controller createAction i can easy get my user entities to show them in my project form (project <--> user many-to-many).
But know im struggling, would it be better to create repository classes and inject this to my controllers instead of the doctrine entity manager, so i can filtering etc all my entities?
Second question:
When i want to filter my projects (e.g by user)
where should i do this ... in simpler slim projects i created Collection classes and injected them all of my entities and after that i called a filter method in my collection ... but the problem there is, i just loaded all entities from my database to the collection. In larger application i think there are to many entities loaded from the Database?
Third Question (Conclusion):
When i want to load data from the db to my Controllers whats best Practice here?
Load it from the entity manager ?
Load it from a Repository (the Repository load it from the entity manager)?
Load it from a Collection (the Collection loads data from the repository class and the repository loads data from the entity manager)?
I did not thought about Pagination #all... thats what i have to do next ... but there are many questions similar to my other questions.
(I know there is a zend module for this .. but have no idea how this works.. have too learn this too)
Im thankful for every hint, meaning etc.
Answers to this question are possibly all opinion based. I would say it is all about personal preference. There is no such thing as best practice here it all depends on what you will do in your controller. On top of that you can easily get a repository from your entity-manager if you need it:
$userRepository = $entityManager->getRepository('Application\Entity\User');
A more common might be to make a custom UserService (a wrapper class) around your repository/entity-manager that you populate with the custom methods you would like to use with your User resources.
I hope this helps you a bit...

Qt project structure - advice needed

I'm currently working on a project based on Qt4/QtCreator. I'd like to ask You for advice on how to organize my application.
There are 3 seperate tools, each has it's own view. All views are integrated in main window as non-closable tabs. I've prepare 3 views: Tool1View, Tool2View, Tool3View
Each tool is suppose to perform some task triggered by user actions. But these are not database related operations (list/add/modify...) - at least the user is not going add/modify/list records in gui elements.
I am thinking to implement each tool in 2 classes:
First class ToolXView implementing the widget and all tasks related to gui changes.
Second class ToolX implementing application logic. Member functions of this class are triggered by View class. Whenever this class has to update GUI elements it cals specialised functions in View class. So no direct calls to widgets are made from here.
View class and logic class will be linked with each other to allow 2 way communication.
Now I'm wondering if this is a good way to go. Please advice me based on Your experience.
I'm planning to encapsulate pointer to logic class as a property of a view class and pointer to view class as a property of logic class. This way I plan to integrade them.
Should I use signals/slots to provide comuncation or just call member functions ?
I'll have to store some data in QtSql database. Should I provide a seperate class for database access. Or just implement sepereate member function inside Logic class ?
How do You name Your classes. Is this scheme good or should I change it ?
Thanks for help. I appreciate your comments.
Using the mvc architecture is great.
1 & 2 - In the link above you will see the UML diagram of a mvc architecture. Regarding it, I would connect view signals to controller methods and then call a view method from controller.
3 - Regarding Database access I would add a Data Access part in your architecture which is specialized to the data access. You can have an interface to define the data access object signature and then implement it in a specialized class for database (So you will be able to change data location without modifying the whole application).
4 - You class naming seems good. But I would go further and call classes:
For view : ClassNameView
For Controller : ClassNameController
For DataAccessObject : ClassNameDAO
Model : ClassName (and IClassName for interface)
Hope that helps