Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A good folder structure for Xamarin form projects [closed]

Since I'm new to Xamarin forms, I'm not quite aware of How to arrange your Xamarin form project in a good folder structure?

For eg. I have a project which contains following files :

  1. Network calling
  2. Database handling
  3. Views creations
  4. Model-View bindings
  5. Utilities etc.

NOTE: Xamarin Form itself has Xamarin.iOS and Xamarin.Android solution folders and the above mentioned files could be common to both Android and iOS.

like image 201
Vineet Ravi Avatar asked Jun 23 '17 04:06

Vineet Ravi


People also ask

What is the project structure of Xamarin forms?

By default, a Xamarin Project consists of three Projects: Xamarin main Project (Where we will be sharing our Business logic and UI (User interface) throughout the application. Xamarin Android Project (We can do platform-specific changes if required natively, and we can also access native features).

Is Xamarin forms going away?

In May 2020, Microsoft announced that Xamarin. Forms, a major component of its mobile app development framework, would be deprecated in November 2021 in favour of a new . Net based product called MAUI - Multiform App User Interface.

Has Xamarin deprecated?

Forms , it still supports Android, iOS, and UWP . In other word , Xamarin. Android will not be deprecated in the feature, but maybe it will be renamed to . Net-Android or something else.

What are the types of layout control in the Xamarin forms?

It can either be “Horizontal” or “Vertical”. And the height and width can be set from the property called “HeightRequest” and “WidthRequest”. The picture below shows the Stack layout.

What file types does Xamarin form support?

NOTE: Xamarin Form itself has Xamarin.iOS and Xamarin.Android solution folders and the above mentioned files could be common to both Android and iOS. Show activity on this post. Data Layer – Non-volatile data persistence, likely to be a SQLite database but could be implemented with XML files or any other suitable mechanism.

What is the architecture of a Xamarin project in Visual Studio?

Today we will be discussing the architecture of a Xamarin Project in Visual Studio on Mac. By default, a Xamarin Project consists of three Projects: Xamarin main Project (Where we will be sharing our Business logic and UI (User interface) throughout the application.

How to sort folders by name?

For the convenience of displaying folders, name them, starting with the sequence number. When you sort folders by name you are guaranteed to get a single display for all projects, which will significantly simplify the work and add consistency to the system.

What is a project folder and how to use it?

From a project folder you dig right into processes (middle level), while each process contains a form-factor separation or, more often, nothing. Such system is effective if: Project must be done as soon as possible: as a freelancer or an agency you are up to win a tender


2 Answers

There isn't a full agreement on which option is better - using Shared projects or Portable Class Libraries, but those are options for code sharing.

Personally I agree with Miguel de Icaza, Xamarin lead that if you don't share your code across other apps Shared projects are better, but as he said some people in Xamarin think opposite.

like image 158
Ivan Ičin Avatar answered Oct 10 '22 11:10

Ivan Ičin


Typical Application Layers

  • Data Layer – Non-volatile data persistence, likely to be a SQLite database but could be implemented with XML files or any other suitable mechanism.
  • Data Access Layer – Wrapper around the Data Layer that provides Create, Read, Update, Delete (CRUD) access to the data without exposing implementation details to the caller. For example, the DAL may contain SQL statements to query or update the data but the referencing code would not need to know this.
  • Business Layer – (sometimes called the Business Logic Layer or BLL) contains business entity definitions (the Model) and business logic. Candidate for Business Façade pattern.
  • Service Access Layer – Used to access services in the cloud: from complex web services (REST, JSON, WCF) to simple retrieval of data and images from remote servers. Encapsulates the networking behavior and provides a simple API to be consumed by the Application and UI layers.
  • Application Layer – Code that’s typically platform specific (not generally shared across platforms) or code that is specific to the application (not generally reusable). A good test of whether to place code in the Application Layer versus the UI Layer is (a) to determine whether the class has any actual display controls or (b) whether it could be shared between multiple screens or devices (eg. iPhone and iPad).
  • User Interface (UI) Layer – The user-facing layer, contains screens, widgets and the controllers that manage them.

enter image description here

Each of these layers represents an individual Solution Folder. And each Layer should also be a different ClassLibrary(Portable)(see Encapsulation)

Also worth reading in this documentation:

Encapsulation, Separation of Responsibilities, Polymorphism

Taken from Xamarin Developer Guide - Achitecture

I also found some more info here.

like image 16
Felix D. Avatar answered Oct 10 '22 10:10

Felix D.