Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I am working on C# web application and i build various application with simple project structure like image is given below.
Basically i want to know about the best project structure of large web application on C#? or is above project structure(in the image) is right way to build an web application ?
Now i want to improve my project structure. So where should i start improve myself to build an lage web application.
There's no "best way", but there are some "worst ways". I see that you are using some of the "worst ways". Here are a few of them:
Do not use web site "projects". They are not projects. They're just whatever happens to be in a particular directory tree. I notice that you have ~1.pdf in your project, or did you just happen to have it in the same folder? Use Web Application Projects instead - use File->New Project.
Do not use App_Code. App_Code is for a small number of code files which are compiled at runtime. No other kind of "project" has code compiled at runtime. This is a bizarre corruption of computer programming.
At the very least, create separate folders for the different parts of your code which are not in code-behind. You can start with a single folder (maybe called "My_Code", not App_Code), and when you start to get "too many" files in that one folder, start separating the files based on their function. Keep one class per file, and it will become obvious quickly that different sets of classes have different sets of functions. For instance, you'll find you have a set of classes related to database access. Put those into a "DataAccess" folder.
Better, once you find that you have many such folders, move each of the folders out into their own class library project. This way, you don't have to jump right into a complex project structure - the structure can evolve over time.
And if you wind up in ten years with only three classes in My_Code, then you have saved yourself the waste of creating tiny class libraries.
You may have too much code in your code behind. I can't see it, but projects which have the first two symptoms usually have the third. Your codebehind should only have code in it that directly involves user interface - for instance, it can call a method to fetch data to bind to a data bound control, but the code to fetch the data should be in a different class, not in the codebehind. This different class should not be in App_Code, as I say in #2.
Are you using source control? I don't see any source control icons on your project icons. Use source control. Visual Studio Online is free for up to five users, and allows you to use either TFS or Git for source control, as well as providing work item tracking, automated builds and quite a bit more. For free.
I don't think there is really a correct way to structure a project. It depends on what the goals of the project our and your plans for implementation. Each project is different and have will different requirements.
I would go with the most logical approach for your particular project. Whether that's grouping similar components together or grouping whole sub-systems together.
You should carefully analyze your requirements up front before you even begin development and plan your structure accordingly. Having a good plan before you begin coding will save you a bunch of hassle down-stream if things aren't working out and you need to restructure.
I would suggest reading a book like Code Complete, it'll give you excellent tips on how to plan and structure your projects. You can find it here: Code Complete
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I have a relatively comprehensive solution that contains about 20 projects. One of the projects is "Utils", which I would like to have shared for other solutions. Unfortunately, if I added this project to another solution as a linked project, then this project didn't upload me to Git for this solution, so then teamwork is not possible. Therefore, I am looking for a solution to achieve that I can share the source codes of this project between the individual solutions. I use VS2019 and as a Git repository xxx.visualstudio.com. Thanks for the advice.
If doing a nuget package is not a solution for you because it add too much friction (even if you could also give access to the util repository), and that you want to be able to update the "Utils" source directly from the sln file, then the solution for you is to use Git submodules.
From the documentation:
It often happens that while working on one project, you need to use another project from within it. Perhaps it’s a library that a third party developed or that you’re developing separately and using in multiple parent projects. A common issue arises in these scenarios: you want to be able to treat the two projects as separate yet still be able to use one from within the other.
You will have to create a repository for the "Utils" code and include it in the other(s) repositories as submodules.
But Visual Studio still no support it...
It's not crippling because you could still use it from the command line or from an external git GUI that support it (like GitExtensions for example).
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I am trying to build a large application using ASP.NET MVC and entity frameworks. I know this project will become very large at some point so I want to make sure I design it in a way to be able to manage it without lots of unnecessary work specially when I have more programmers helping me down the road.
Another thing I like to consider is the application deployment. I don't want to have to keep compiling my application every time I make update or add new section to my application.
I believe using the MVC design will keep my code clean and easier to maintain. But one thing I really want to enforce is a module design to keep my files organized.
Based on some searching I have done, three things came up Areas, MEF and MAF which seems to be based off the same idea.
I also learned that MAF may be an over kill for most projects where MEF is more in the lines of what I may be looking for.
Most of the articles that I found are at least 2 years old and talks about ASP.NET MVC 4. I am not sure how relevant that is to ASP.NET MVC 5 or ASP.NET MVC 6.
What is confusing to me is that MEF is a framework and ASP.NET MVC is another framework. Is it possible to use the two frameworks to get an MVC design with module base application that allows me to organize my file and not to have to compile my application every time I need to make an update or add a new module?
Is the combination of MVC and MEF consider a good start for a large application? Is there a better idea that I should consider when designing my application?
I don't think MEF is the answer to what you're looking for. MEF was designed with the idea of giving to the developers the ability to create a "pluggable" architecture.
Imagine to develop an app whose core will be shared among different clients, but with some custom modules for some of them. Then MEF is what you're looking for.
Instead, from what you're saying, I think you're just trying to create a tidy and solid architecture, easy to maintain in the future. You don't need MEF for that.
Here is a good article about how to structure big MVC applications keeping in mind the principle of separation of concerns: https://chsakell.com/2015/02/15/asp-net-mvc-solution-architecture-best-practices/
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have a small simple project on building a clickable interactive map of our school.
The challenge is to create a clickable parcel of map and add an animation
directing the user from point A to B using the given roads/hallways on the map. Moreover, I would like to create a database that allows the user to view the information for that specific parcel of map when clicked.
I'm using C# to program this one. My application is Visual Studio 2010
Example Links:
https://www.youtube.com/watch?v=tbinL2pg5Hs
http://www.wayfinderkiosk.com/
QUESTIONS:
What are the processes(step-by-step) on creating this project?
What applications should I need for programming, database, animating, drawing etc.?
Decide on the platform you will be using: WinForms, WPF, WinRT, ASP... If your project description includes the platform then you know; if not keep the question in mind!
Get your resources. Get the map and a list of all the places you will work with. Also all the extras like the descriptions and photos etc. Get this chore out of the way now. It'll help you to get a feeling for the amount of things you will put into the project.
Know your clients. An older kiosk system runs only only a few kiosks. Today maybe you need/want to have it run on the web and on portable devices. This will make a difference in not just for screen sizes but also in the number of possible routes..
Define user input controls. Keyboard? Mouse? Touch? Which buttons? You need a complete list!
Define the user interactions. Completely. Try to make tables of states the system can go through.
Try to decide on how the path finding should work. This anything but trivial, as soon as you want to include more than a few points.. You can have a set of ready made paths or try to find them or build them from a list of partial paths. This may well be the toughest part of it. Some folks believe in 'Hardest First' other in 'Hardest Last'. I believe that the first thing is to understand the hard parts well enough to get a feeling for them and to decide then.
Well that is really just a start, off the top of my head.
Good luck and have fun!!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I have written a windows form app in C#, but I want to turn it into native code for ASP.NET so I can build a webapp around it. However, I've never used ASP.NET and I'm not sure how to approach this. I've looked around and seen libraries such as VisualJS.Net, but it looks confusing and I'm not sure if I can seamlessly integrate it into my app without causing problems later on. Could someone lead me towards the right direction?
Thanks!
So if I well understand, you would like to "transform" a Windows Forms app into a ASP.NET. The problem with this approach, is that those two technologies are like day and night. They don't have the same lifecycle at all. Windows applications are by definition stateful. This means that they keep their state in memory and they don't need to rebuild it often (maybe at the loading of a file). Web applications however are completely stateless. The server receives a request, processes it and returns web content (HTML, JSON and whatever is needed). If the server is again contacted with new information, the state must be rebuilt (with the help of cookies, sessions, etc).*
However, what you can do the ease those problems is the following. If you separate your concerns, you can more easily reuse your business logic and your data and just re-code the view of your application. This means that you must separate what belongs to a View technology (WinForms, ASP.NET) from the model itself. There are numerous patterns to support this : MVC, MVP, MVVM. Respecting GRASP patterns also helps.
With that in mind, you could have three solutions : One containing your common code, one containing the logic that belongs to WinForms and another one that contains your ASP.NET logic. It's easier said than done, but this should be the way to go.
You can't turn an apple into an orange. Those two technologies are so different, that you will be better off rewriting the application from scratch, and taking advantage of all the goodies available in ASP.Net MVC 5.
Technically speaking one could devise some type of a converter, but it would potentially promote bad coding practices, something you should avoid.
Start learning MVC 5, you will be better off in the end.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm not sure if I'm going to be able to explain it right since I'm quite sure I don't know the correct terminology involved with it, which is also why I'm having a difficult time Googling for answers.
Essentially, I'm looking to develop a program that serves as a web site. It'll run constantly (like a service) and will return HTML when an outside user sends an HTTP request thru a browser or similar to a specific port on the computer this program runs on. Basically, this program will perform various background errands throughout the day but I want to be able to expose a web front end (almost like how you would with standard WinForms, but I want to be able to access it remotely) to be able to configure it, check the status of tasks, and otherwise interact with it.
I'm looking to use .Net, but I'm open to using something more universal like Java too. Someone with experience in this area would be helpful to explain any pain points you've encountered and suggestions on how to get started.
You can do it in C# with the HttpListener class.
I published an example some time back. See A Simple Http Server.
Although you might consider whether you really want to operate at that low level. I have written a fairly complex server based on HttpListener, and if I had it to do over again I'd probably just bite the bullet and use ASP.NET. There is a bit of a learning curve, but unless your server is incredibly small and simple, an ASP.NET application will be a lot easier to write and will likely be more robust.
Here is a simple example on how to do it in C# using the HttpServer class:
http://www.codeproject.com/Articles/137979/Simple-HTTP-Server-in-C
You are doing at least 2 different things, so you should probably create a Solution in Visual Studio.NET with one project for each purpose (You can have many projects in a solution), probably with at least one Data Access project as well (of type Class Library). If the solution does things at certain times of the day, then those can be Console Applications that run through task scheduler, rather than one of more services. Services are better suited to things other than simple scheduled tasks. A Web Application project can serve up your html.