<commit_before># Design Idea

## Basic Architecture

![Basic Architecture](../Resources/ArchitecturePreview.png)

## Design Idea

ZIKRouter uses protocol to manage moudles. The advantages of interface oriented programming:

* Strict type safety with compile time check
* Reduce refactoring costs with compile time check
* Make sure the module implements its protocol
* Declare module's dependencies with protocol
* Avoid using non-existent module with parameter checking when routing
* Separate required protocol and provided protocol to thoroughly decouple

## Why ZIKRouter？

Comparing to other module manage or router frameworks, what's the advantages of ZIKRouter?

### URL Router

ZIKRouter manages modules with protocol, but most of router frameworks use URL matching to get modules.

Advantages of URL router:

* Highly dynamic
* East to manage route rules in multi platforms
* East to use URL Scheme

Disadvantages of URL router:

* Type of parameters is limited when routing, and there is no compile time check
* Only for view module, not for any service module
* Can't declare module's interface, highly rely on documentation. So it's not that safe when refactoring
* Hard to manage route strings
* Can't separate required protocol and provided protocol. So you can't thoroughly decouple

#### Improvement

All disadvantages of URL router can be resolved if we use protocol to manage modules. And ZIKRouter also allows you to get router with string identifier. So it's easy to use ZIKRouter with other URL router frameworks.

### Module Manager with Reflection

Some module manager use runtime and category features in Objective-C to get moudles. Such as getting class with `NSClassFromString `, then use `performSelector:` `NSInvocation`to perform methods.

The general implementation is adding new interfaces with categories in the module manager, and in the category method, use strings to get class with runtime and perform methods.

Advantages:

* Compile time check for category methods<commit_msg>fix spelling mistake<commit_after># Design Idea

## Basic Architecture

![Basic Architecture](../Resources/ArchitecturePreview.png)

## Design Idea

ZIKRouter uses protocol to manage modules. The advantages of interface oriented programming:

* Strict type safety with compile time check
* Reduce refactoring costs with compile time check
* Make sure the module implements its protocol
* Declare module's dependencies with protocol
* Avoid using non-existent module with parameter checking when routing
* Separate required protocol and provided protocol to thoroughly decouple

## Why ZIKRouter？

Comparing to other module manage or router frameworks, what's the advantages of ZIKRouter?

### URL Router

ZIKRouter manages modules with protocol, but most of router frameworks use URL matching to get modules.

Advantages of URL router:

* Highly dynamic
* East to manage route rules in multi platforms
* East to use URL Scheme

Disadvantages of URL router:

* Type of parameters is limited when routing, and there is no compile time check
* Only for view module, not for any service module
* Can't declare module's interface, highly rely on documentation. So it's not that safe when refactoring
* Hard to manage route strings
* Can't separate required protocol and provided protocol. So you can't thoroughly decouple

#### Improvement

All disadvantages of URL router can be resolved if we use protocol to manage modules. And ZIKRouter also allows you to get router with string identifier. So it's easy to use ZIKRouter with other URL router frameworks.

### Module Manager with Reflection

Some module manager use runtime and category features in Objective-C to get modules. Such as getting class with `NSClassFromString `, then use `performSelector:` `NSInvocation`to perform methods.

The general implementation is adding new interfaces with categories in the module manager, and in the category method, use strings to get class with runtime and perform methods.

Advantages:

* Compile time check for category methods
{'fraction_non_alphanumeric': 0.042627013630731105, 'fraction_numerical': 0.0, 'mean_word_length': 4.979259259259259, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '399660', 'n_tokens_mistral': 984, 'n_tokens_neox': 910, 'n_words': 557}