-
Notifications
You must be signed in to change notification settings - Fork 1
Lesson2B
Some keywords to understand
- Constructor
- Encapsulation
- Property, Automatic property
- Static
- Access Modifier (public, protected, private)
- Inheritance
- Polymorphism
- Virtual & Override
- Interface
This one can be learnt through reading book or any common online resource. This knowledge applicable throughout many programming fields, good to know even if not for this project.
XML-like UI styling, makes creating UI easy.
Most commonly used:
- StackLayout
- Grid
- Label
- Entry
- Button
This one pretty much learn by experience. A lot of domain specific knowledge, only 30-40% of things learnt here are applicable elsewhere.
Stands for Model-View-ViewModel
It is a software architectural pattern, to separate UI logic from business logic. Good to understand the basic principles of software architecture, applicable to all big software projects. Sounds easy but it is extremely difficult to resolve edge cases and still remain clean on architecture.
- Model - pretty much plain data store (like the Item class)
- View - pretty much all XAML
- ViewModel - the data source of the xaml
- Service - this is where most of the business logic reside, i.e. getting data from server and filtering, navigation, login, notifications, etc.
Avoid any code in the .xaml.cs file as far as possible. Even if there is any, make sure it only handles UI, no logic
Isolating a piece of code and test it.
Very similar to programming challenge:
- give some input
- run the function
- determine if output is expected
Usually most code will rely on something else too e.g. your data processing also involves writing to a log file for error tracking, how can you test only the data processing part?
Overtesting. Start to test for implementation, such as verifying that Service1.Function1 has been called once, Service1.Function2 has been called once, and Service1.Function3 is never called.
This will result in very fragile tests, minor changes in code will result in changing many tests to pass.
- Create a basic Xamarin.Forms app
- Edit the MainPage.xaml as you see fit
- Create a MainViewModel.cs and bind the data of MainPage to MainViewModel
- Add buttons in MainPage, bind to Commands in MainViewModel, which wraps around some function inside MainViewModel.
Example command:
public ICommand Button1Command => new Command(Function1);
private void Function1(){
Debug.WriteLine("Function1 called");
Content += " A"; //assumes you have already binded Content, also note that if you did not implement INotifyPropertyChanged correctly your View will not update even as Content changes
}
- Test if binding works
- Create a Console application
- Create some class