mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-10-13 14:16:02 +00:00
docs: add editorconfig + formatting
This commit is contained in:
1 parent
f80cc468b2
commit
6322d538cd
8 files changed
+371
-28
No files matched your search
+340
@@ -0,0 +1,340 @@
|
|||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
|
insert_final_newline = false
|
||||||
|
max_line_length = 120
|
||||||
|
tab_width = 4
|
||||||
|
ij_continuation_indent_size = 8
|
||||||
|
ij_formatter_off_tag = @formatter:off
|
||||||
|
ij_formatter_on_tag = @formatter:on
|
||||||
|
ij_formatter_tags_enabled = true
|
||||||
|
ij_smart_tabs = false
|
||||||
|
ij_visual_guides =
|
||||||
|
ij_wrap_on_typing = false
|
||||||
|
|
||||||
|
[*.java]
|
||||||
|
indent_size = 2
|
||||||
|
max_line_length = 100
|
||||||
|
ij_continuation_indent_size = 4
|
||||||
|
ij_java_align_consecutive_assignments = false
|
||||||
|
ij_java_align_consecutive_variable_declarations = false
|
||||||
|
ij_java_align_group_field_declarations = false
|
||||||
|
ij_java_align_multiline_annotation_parameters = false
|
||||||
|
ij_java_align_multiline_array_initializer_expression = false
|
||||||
|
ij_java_align_multiline_assignment = false
|
||||||
|
ij_java_align_multiline_binary_operation = false
|
||||||
|
ij_java_align_multiline_chained_methods = false
|
||||||
|
ij_java_align_multiline_deconstruction_list_components = true
|
||||||
|
ij_java_align_multiline_extends_list = false
|
||||||
|
ij_java_align_multiline_for = true
|
||||||
|
ij_java_align_multiline_method_parentheses = false
|
||||||
|
ij_java_align_multiline_parameters = true
|
||||||
|
ij_java_align_multiline_parameters_in_calls = false
|
||||||
|
ij_java_align_multiline_parenthesized_expression = false
|
||||||
|
ij_java_align_multiline_records = true
|
||||||
|
ij_java_align_multiline_resources = true
|
||||||
|
ij_java_align_multiline_ternary_operation = false
|
||||||
|
ij_java_align_multiline_text_blocks = false
|
||||||
|
ij_java_align_multiline_throws_list = false
|
||||||
|
ij_java_align_subsequent_simple_methods = false
|
||||||
|
ij_java_align_throws_keyword = false
|
||||||
|
ij_java_align_types_in_multi_catch = true
|
||||||
|
ij_java_annotation_parameter_wrap = off
|
||||||
|
ij_java_array_initializer_new_line_after_left_brace = false
|
||||||
|
ij_java_array_initializer_right_brace_on_new_line = false
|
||||||
|
ij_java_array_initializer_wrap = normal
|
||||||
|
ij_java_assert_statement_colon_on_next_line = false
|
||||||
|
ij_java_assert_statement_wrap = normal
|
||||||
|
ij_java_assignment_wrap = normal
|
||||||
|
ij_java_binary_operation_sign_on_next_line = false
|
||||||
|
ij_java_binary_operation_wrap = normal
|
||||||
|
ij_java_blank_lines_after_anonymous_class_header = 0
|
||||||
|
ij_java_blank_lines_after_class_header = 0
|
||||||
|
ij_java_blank_lines_after_imports = 1
|
||||||
|
ij_java_blank_lines_after_package = 1
|
||||||
|
ij_java_blank_lines_around_class = 1
|
||||||
|
ij_java_blank_lines_around_field = 0
|
||||||
|
ij_java_blank_lines_around_field_in_interface = 0
|
||||||
|
ij_java_blank_lines_around_initializer = 1
|
||||||
|
ij_java_blank_lines_around_method = 1
|
||||||
|
ij_java_blank_lines_around_method_in_interface = 1
|
||||||
|
ij_java_blank_lines_before_class_end = 0
|
||||||
|
ij_java_blank_lines_before_imports = 1
|
||||||
|
ij_java_blank_lines_before_method_body = 0
|
||||||
|
ij_java_blank_lines_before_package = 1
|
||||||
|
ij_java_block_brace_style = end_of_line
|
||||||
|
ij_java_block_comment_add_space = false
|
||||||
|
ij_java_block_comment_at_first_column = true
|
||||||
|
ij_java_builder_methods =
|
||||||
|
ij_java_call_parameters_new_line_after_left_paren = false
|
||||||
|
ij_java_call_parameters_right_paren_on_new_line = false
|
||||||
|
ij_java_call_parameters_wrap = normal
|
||||||
|
ij_java_case_statement_on_separate_line = true
|
||||||
|
ij_java_catch_on_new_line = false
|
||||||
|
ij_java_class_annotation_wrap = split_into_lines
|
||||||
|
ij_java_class_brace_style = end_of_line
|
||||||
|
ij_java_class_count_to_use_import_on_demand = 999
|
||||||
|
ij_java_class_names_in_javadoc = 1
|
||||||
|
ij_java_deconstruction_list_wrap = normal
|
||||||
|
ij_java_do_not_indent_top_level_class_members = false
|
||||||
|
ij_java_do_not_wrap_after_single_annotation = false
|
||||||
|
ij_java_do_not_wrap_after_single_annotation_in_parameter = false
|
||||||
|
ij_java_do_while_brace_force = always
|
||||||
|
ij_java_doc_add_blank_line_after_description = true
|
||||||
|
ij_java_doc_add_blank_line_after_param_comments = false
|
||||||
|
ij_java_doc_add_blank_line_after_return = false
|
||||||
|
ij_java_doc_add_p_tag_on_empty_lines = true
|
||||||
|
ij_java_doc_align_exception_comments = true
|
||||||
|
ij_java_doc_align_param_comments = true
|
||||||
|
ij_java_doc_do_not_wrap_if_one_line = false
|
||||||
|
ij_java_doc_enable_formatting = true
|
||||||
|
ij_java_doc_enable_leading_asterisks = true
|
||||||
|
ij_java_doc_indent_on_continuation = false
|
||||||
|
ij_java_doc_keep_empty_lines = true
|
||||||
|
ij_java_doc_keep_empty_parameter_tag = true
|
||||||
|
ij_java_doc_keep_empty_return_tag = true
|
||||||
|
ij_java_doc_keep_empty_throws_tag = true
|
||||||
|
ij_java_doc_keep_invalid_tags = true
|
||||||
|
ij_java_doc_param_description_on_new_line = false
|
||||||
|
ij_java_doc_preserve_line_breaks = false
|
||||||
|
ij_java_doc_use_throws_not_exception_tag = true
|
||||||
|
ij_java_else_on_new_line = false
|
||||||
|
ij_java_entity_dd_prefix =
|
||||||
|
ij_java_entity_dd_suffix = EJB
|
||||||
|
ij_java_entity_eb_prefix =
|
||||||
|
ij_java_entity_eb_suffix = Bean
|
||||||
|
ij_java_entity_hi_prefix =
|
||||||
|
ij_java_entity_hi_suffix = Home
|
||||||
|
ij_java_entity_lhi_prefix = Local
|
||||||
|
ij_java_entity_lhi_suffix = Home
|
||||||
|
ij_java_entity_li_prefix = Local
|
||||||
|
ij_java_entity_li_suffix =
|
||||||
|
ij_java_entity_pk_class = java.lang.String
|
||||||
|
ij_java_entity_ri_prefix =
|
||||||
|
ij_java_entity_ri_suffix =
|
||||||
|
ij_java_entity_vo_prefix =
|
||||||
|
ij_java_entity_vo_suffix = VO
|
||||||
|
ij_java_enum_constants_wrap = normal
|
||||||
|
ij_java_extends_keyword_wrap = normal
|
||||||
|
ij_java_extends_list_wrap = normal
|
||||||
|
ij_java_field_annotation_wrap = split_into_lines
|
||||||
|
ij_java_field_name_prefix =
|
||||||
|
ij_java_field_name_suffix =
|
||||||
|
ij_java_filter_class_prefix =
|
||||||
|
ij_java_filter_class_suffix =
|
||||||
|
ij_java_filter_dd_prefix =
|
||||||
|
ij_java_filter_dd_suffix =
|
||||||
|
ij_java_finally_on_new_line = false
|
||||||
|
ij_java_for_brace_force = always
|
||||||
|
ij_java_for_statement_new_line_after_left_paren = false
|
||||||
|
ij_java_for_statement_right_paren_on_new_line = false
|
||||||
|
ij_java_for_statement_wrap = normal
|
||||||
|
ij_java_generate_final_locals = false
|
||||||
|
ij_java_generate_final_parameters = false
|
||||||
|
ij_java_if_brace_force = always
|
||||||
|
ij_java_imports_layout = $*,|,*
|
||||||
|
ij_java_indent_case_from_switch = true
|
||||||
|
ij_java_insert_inner_class_imports = false
|
||||||
|
ij_java_insert_override_annotation = true
|
||||||
|
ij_java_keep_blank_lines_before_right_brace = 2
|
||||||
|
ij_java_keep_blank_lines_between_package_declaration_and_header = 2
|
||||||
|
ij_java_keep_blank_lines_in_code = 2
|
||||||
|
ij_java_keep_blank_lines_in_declarations = 2
|
||||||
|
ij_java_keep_builder_methods_indents = false
|
||||||
|
ij_java_keep_control_statement_in_one_line = true
|
||||||
|
ij_java_keep_first_column_comment = true
|
||||||
|
ij_java_keep_indents_on_empty_lines = false
|
||||||
|
ij_java_keep_line_breaks = true
|
||||||
|
ij_java_keep_multiple_expressions_in_one_line = false
|
||||||
|
ij_java_keep_simple_blocks_in_one_line = false
|
||||||
|
ij_java_keep_simple_classes_in_one_line = false
|
||||||
|
ij_java_keep_simple_lambdas_in_one_line = false
|
||||||
|
ij_java_keep_simple_methods_in_one_line = false
|
||||||
|
ij_java_label_indent_absolute = false
|
||||||
|
ij_java_label_indent_size = 0
|
||||||
|
ij_java_lambda_brace_style = end_of_line
|
||||||
|
ij_java_layout_static_imports_separately = true
|
||||||
|
ij_java_line_comment_add_space = false
|
||||||
|
ij_java_line_comment_add_space_on_reformat = false
|
||||||
|
ij_java_line_comment_at_first_column = true
|
||||||
|
ij_java_listener_class_prefix =
|
||||||
|
ij_java_listener_class_suffix =
|
||||||
|
ij_java_local_variable_name_prefix =
|
||||||
|
ij_java_local_variable_name_suffix =
|
||||||
|
ij_java_message_dd_prefix =
|
||||||
|
ij_java_message_dd_suffix = EJB
|
||||||
|
ij_java_message_eb_prefix =
|
||||||
|
ij_java_message_eb_suffix = Bean
|
||||||
|
ij_java_method_annotation_wrap = split_into_lines
|
||||||
|
ij_java_method_brace_style = end_of_line
|
||||||
|
ij_java_method_call_chain_wrap = normal
|
||||||
|
ij_java_method_parameters_new_line_after_left_paren = false
|
||||||
|
ij_java_method_parameters_right_paren_on_new_line = false
|
||||||
|
ij_java_method_parameters_wrap = normal
|
||||||
|
ij_java_modifier_list_wrap = false
|
||||||
|
ij_java_multi_catch_types_wrap = normal
|
||||||
|
ij_java_names_count_to_use_import_on_demand = 999
|
||||||
|
ij_java_new_line_after_lparen_in_annotation = false
|
||||||
|
ij_java_new_line_after_lparen_in_deconstruction_pattern = true
|
||||||
|
ij_java_new_line_after_lparen_in_record_header = false
|
||||||
|
ij_java_packages_to_use_import_on_demand =
|
||||||
|
ij_java_parameter_annotation_wrap = normal
|
||||||
|
ij_java_parameter_name_prefix =
|
||||||
|
ij_java_parameter_name_suffix =
|
||||||
|
ij_java_parentheses_expression_new_line_after_left_paren = false
|
||||||
|
ij_java_parentheses_expression_right_paren_on_new_line = false
|
||||||
|
ij_java_place_assignment_sign_on_next_line = false
|
||||||
|
ij_java_prefer_longer_names = true
|
||||||
|
ij_java_prefer_parameters_wrap = false
|
||||||
|
ij_java_record_components_wrap = normal
|
||||||
|
ij_java_repeat_annotations =
|
||||||
|
ij_java_repeat_synchronized = true
|
||||||
|
ij_java_replace_instanceof_and_cast = false
|
||||||
|
ij_java_replace_null_check = true
|
||||||
|
ij_java_replace_sum_lambda_with_method_ref = true
|
||||||
|
ij_java_resource_list_new_line_after_left_paren = false
|
||||||
|
ij_java_resource_list_right_paren_on_new_line = false
|
||||||
|
ij_java_resource_list_wrap = normal
|
||||||
|
ij_java_rparen_on_new_line_in_annotation = false
|
||||||
|
ij_java_rparen_on_new_line_in_deconstruction_pattern = true
|
||||||
|
ij_java_rparen_on_new_line_in_record_header = false
|
||||||
|
ij_java_servlet_class_prefix =
|
||||||
|
ij_java_servlet_class_suffix =
|
||||||
|
ij_java_servlet_dd_prefix =
|
||||||
|
ij_java_servlet_dd_suffix =
|
||||||
|
ij_java_session_dd_prefix =
|
||||||
|
ij_java_session_dd_suffix = EJB
|
||||||
|
ij_java_session_eb_prefix =
|
||||||
|
ij_java_session_eb_suffix = Bean
|
||||||
|
ij_java_session_hi_prefix =
|
||||||
|
ij_java_session_hi_suffix = Home
|
||||||
|
ij_java_session_lhi_prefix = Local
|
||||||
|
ij_java_session_lhi_suffix = Home
|
||||||
|
ij_java_session_li_prefix = Local
|
||||||
|
ij_java_session_li_suffix =
|
||||||
|
ij_java_session_ri_prefix =
|
||||||
|
ij_java_session_ri_suffix =
|
||||||
|
ij_java_session_si_prefix =
|
||||||
|
ij_java_session_si_suffix = Service
|
||||||
|
ij_java_space_after_closing_angle_bracket_in_type_argument = false
|
||||||
|
ij_java_space_after_colon = true
|
||||||
|
ij_java_space_after_comma = true
|
||||||
|
ij_java_space_after_comma_in_type_arguments = true
|
||||||
|
ij_java_space_after_for_semicolon = true
|
||||||
|
ij_java_space_after_quest = true
|
||||||
|
ij_java_space_after_type_cast = true
|
||||||
|
ij_java_space_before_annotation_array_initializer_left_brace = false
|
||||||
|
ij_java_space_before_annotation_parameter_list = false
|
||||||
|
ij_java_space_before_array_initializer_left_brace = true
|
||||||
|
ij_java_space_before_catch_keyword = true
|
||||||
|
ij_java_space_before_catch_left_brace = true
|
||||||
|
ij_java_space_before_catch_parentheses = true
|
||||||
|
ij_java_space_before_class_left_brace = true
|
||||||
|
ij_java_space_before_colon = true
|
||||||
|
ij_java_space_before_colon_in_foreach = true
|
||||||
|
ij_java_space_before_comma = false
|
||||||
|
ij_java_space_before_deconstruction_list = false
|
||||||
|
ij_java_space_before_do_left_brace = true
|
||||||
|
ij_java_space_before_else_keyword = true
|
||||||
|
ij_java_space_before_else_left_brace = true
|
||||||
|
ij_java_space_before_finally_keyword = true
|
||||||
|
ij_java_space_before_finally_left_brace = true
|
||||||
|
ij_java_space_before_for_left_brace = true
|
||||||
|
ij_java_space_before_for_parentheses = true
|
||||||
|
ij_java_space_before_for_semicolon = false
|
||||||
|
ij_java_space_before_if_left_brace = true
|
||||||
|
ij_java_space_before_if_parentheses = true
|
||||||
|
ij_java_space_before_method_call_parentheses = false
|
||||||
|
ij_java_space_before_method_left_brace = true
|
||||||
|
ij_java_space_before_method_parentheses = false
|
||||||
|
ij_java_space_before_opening_angle_bracket_in_type_parameter = false
|
||||||
|
ij_java_space_before_quest = true
|
||||||
|
ij_java_space_before_switch_left_brace = true
|
||||||
|
ij_java_space_before_switch_parentheses = true
|
||||||
|
ij_java_space_before_synchronized_left_brace = true
|
||||||
|
ij_java_space_before_synchronized_parentheses = true
|
||||||
|
ij_java_space_before_try_left_brace = true
|
||||||
|
ij_java_space_before_try_parentheses = true
|
||||||
|
ij_java_space_before_type_parameter_list = false
|
||||||
|
ij_java_space_before_while_keyword = true
|
||||||
|
ij_java_space_before_while_left_brace = true
|
||||||
|
ij_java_space_before_while_parentheses = true
|
||||||
|
ij_java_space_inside_one_line_enum_braces = false
|
||||||
|
ij_java_space_within_empty_array_initializer_braces = false
|
||||||
|
ij_java_space_within_empty_method_call_parentheses = false
|
||||||
|
ij_java_space_within_empty_method_parentheses = false
|
||||||
|
ij_java_spaces_around_additive_operators = true
|
||||||
|
ij_java_spaces_around_annotation_eq = true
|
||||||
|
ij_java_spaces_around_assignment_operators = true
|
||||||
|
ij_java_spaces_around_bitwise_operators = true
|
||||||
|
ij_java_spaces_around_equality_operators = true
|
||||||
|
ij_java_spaces_around_lambda_arrow = true
|
||||||
|
ij_java_spaces_around_logical_operators = true
|
||||||
|
ij_java_spaces_around_method_ref_dbl_colon = false
|
||||||
|
ij_java_spaces_around_multiplicative_operators = true
|
||||||
|
ij_java_spaces_around_relational_operators = true
|
||||||
|
ij_java_spaces_around_shift_operators = true
|
||||||
|
ij_java_spaces_around_type_bounds_in_type_parameters = true
|
||||||
|
ij_java_spaces_around_unary_operator = false
|
||||||
|
ij_java_spaces_within_angle_brackets = false
|
||||||
|
ij_java_spaces_within_annotation_parentheses = false
|
||||||
|
ij_java_spaces_within_array_initializer_braces = false
|
||||||
|
ij_java_spaces_within_braces = false
|
||||||
|
ij_java_spaces_within_brackets = false
|
||||||
|
ij_java_spaces_within_cast_parentheses = false
|
||||||
|
ij_java_spaces_within_catch_parentheses = false
|
||||||
|
ij_java_spaces_within_deconstruction_list = false
|
||||||
|
ij_java_spaces_within_for_parentheses = false
|
||||||
|
ij_java_spaces_within_if_parentheses = false
|
||||||
|
ij_java_spaces_within_method_call_parentheses = false
|
||||||
|
ij_java_spaces_within_method_parentheses = false
|
||||||
|
ij_java_spaces_within_parentheses = false
|
||||||
|
ij_java_spaces_within_record_header = false
|
||||||
|
ij_java_spaces_within_switch_parentheses = false
|
||||||
|
ij_java_spaces_within_synchronized_parentheses = false
|
||||||
|
ij_java_spaces_within_try_parentheses = false
|
||||||
|
ij_java_spaces_within_while_parentheses = false
|
||||||
|
ij_java_special_else_if_treatment = true
|
||||||
|
ij_java_static_field_name_prefix =
|
||||||
|
ij_java_static_field_name_suffix =
|
||||||
|
ij_java_subclass_name_prefix =
|
||||||
|
ij_java_subclass_name_suffix = Impl
|
||||||
|
ij_java_ternary_operation_signs_on_next_line = false
|
||||||
|
ij_java_ternary_operation_wrap = normal
|
||||||
|
ij_java_test_name_prefix =
|
||||||
|
ij_java_test_name_suffix = Test
|
||||||
|
ij_java_throws_keyword_wrap = normal
|
||||||
|
ij_java_throws_list_wrap = normal
|
||||||
|
ij_java_use_external_annotations = false
|
||||||
|
ij_java_use_fq_class_names = false
|
||||||
|
ij_java_use_relative_indents = false
|
||||||
|
ij_java_use_single_class_imports = true
|
||||||
|
ij_java_variable_annotation_wrap = normal
|
||||||
|
ij_java_visibility = public
|
||||||
|
ij_java_while_brace_force = always
|
||||||
|
ij_java_while_on_new_line = false
|
||||||
|
ij_java_wrap_comments = false
|
||||||
|
ij_java_wrap_first_method_in_call_chain = false
|
||||||
|
ij_java_wrap_long_lines = false
|
||||||
|
|
||||||
|
[{*.markdown,*.md}]
|
||||||
|
ij_markdown_force_one_space_after_blockquote_symbol = true
|
||||||
|
ij_markdown_force_one_space_after_header_symbol = true
|
||||||
|
ij_markdown_force_one_space_after_list_bullet = true
|
||||||
|
ij_markdown_force_one_space_between_words = true
|
||||||
|
ij_markdown_format_tables = true
|
||||||
|
ij_markdown_insert_quote_arrows_on_wrap = true
|
||||||
|
ij_markdown_keep_indents_on_empty_lines = false
|
||||||
|
ij_markdown_keep_line_breaks_inside_text_blocks = true
|
||||||
|
ij_markdown_max_lines_around_block_elements = 1
|
||||||
|
ij_markdown_max_lines_around_header = 1
|
||||||
|
ij_markdown_max_lines_between_paragraphs = 1
|
||||||
|
ij_markdown_min_lines_around_block_elements = 1
|
||||||
|
ij_markdown_min_lines_around_header = 1
|
||||||
|
ij_markdown_min_lines_between_paragraphs = 1
|
||||||
|
ij_markdown_wrap_text_if_long = true
|
||||||
|
ij_markdown_wrap_text_inside_blockquotes = true
|
||||||
+5
-5
@@ -22,11 +22,11 @@ compatibility.
|
|||||||
Real-world example
|
Real-world example
|
||||||
|
|
||||||
> Consider that you have some pictures on your memory card and you need to transfer them to your computer. To transfer
|
> Consider that you have some pictures on your memory card and you need to transfer them to your computer. To transfer
|
||||||
> them, you need some kind of adapter that is compatible with your computer ports so that you can attach a memory card to
|
> them, you need some kind of adapter that is compatible with your computer ports so that you can attach a memory card
|
||||||
> your computer. In this case card reader is an adapter.
|
> to your computer. In this case card reader is an adapter. Another example would be the famous power adapter; a
|
||||||
> Another example would be the famous power adapter; a three-legged plug can't be connected to a two-pronged outlet, it
|
> three-legged plug can't be connected to a two-pronged outlet, it needs to use a power adapter that makes it compatible
|
||||||
> needs to use a power adapter that makes it compatible with the two-pronged outlets.
|
> with the two-pronged outlets. Yet another example would be a translator translating words spoken by one person to
|
||||||
> Yet another example would be a translator translating words spoken by one person to another
|
> another
|
||||||
|
|
||||||
In plain words
|
In plain words
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -21,8 +21,8 @@ Decouple an abstraction from its implementation so that the two can vary indepen
|
|||||||
Real-world example
|
Real-world example
|
||||||
|
|
||||||
> Consider you have a weapon with different enchantments, and you are supposed to allow mixing different weapons with
|
> Consider you have a weapon with different enchantments, and you are supposed to allow mixing different weapons with
|
||||||
> different enchantments. What would you do? Create multiple copies of each of the weapons for each of the enchantments or
|
> different enchantments. What would you do? Create multiple copies of each of the weapons for each of the enchantments
|
||||||
> would you just create separate enchantment and set it for the weapon as needed? Bridge pattern allows you to do the
|
> or would you just create separate enchantment and set it for the weapon as needed? Bridge pattern allows you to do the
|
||||||
> second.
|
> second.
|
||||||
|
|
||||||
In Plain Words
|
In Plain Words
|
||||||
|
|||||||
+2
-2
@@ -15,8 +15,8 @@ Allows encoding behavior as instructions for a virtual machine.
|
|||||||
Real world example
|
Real world example
|
||||||
|
|
||||||
> A team is working on a new game where wizards battle against each other. The wizard behavior needs to be carefully
|
> A team is working on a new game where wizards battle against each other. The wizard behavior needs to be carefully
|
||||||
> adjusted and iterated hundreds of times through playtesting. It's not optimal to ask the programmer to make changes each
|
> adjusted and iterated hundreds of times through playtesting. It's not optimal to ask the programmer to make changes
|
||||||
> time the game designer wants to vary the behavior, so the wizard behavior is implemented as a data-driven virtual
|
> each time the game designer wants to vary the behavior, so the wizard behavior is implemented as a data-driven virtual
|
||||||
> machine.
|
> machine.
|
||||||
|
|
||||||
In plain words
|
In plain words
|
||||||
|
|||||||
+6
-6
@@ -24,9 +24,9 @@ again.
|
|||||||
Real world example
|
Real world example
|
||||||
|
|
||||||
> A team is working on a website that provides new homes for abandoned cats. People can post their cats on the website
|
> A team is working on a website that provides new homes for abandoned cats. People can post their cats on the website
|
||||||
> after registering, but all the new posts require approval from one of the site moderators. The user accounts of the site
|
> after registering, but all the new posts require approval from one of the site moderators. The user accounts of the
|
||||||
> moderators contain a specific flag and the data is stored in a MongoDB database. Checking for the moderator flag each
|
> site moderators contain a specific flag and the data is stored in a MongoDB database. Checking for the moderator flag
|
||||||
> time a post is viewed becomes expensive, and it's a good idea to utilize caching here.
|
> each time a post is viewed becomes expensive, and it's a good idea to utilize caching here.
|
||||||
|
|
||||||
In plain words
|
In plain words
|
||||||
|
|
||||||
@@ -36,9 +36,9 @@ Wikipedia says:
|
|||||||
|
|
||||||
> In computing, a cache is a hardware or software component that stores data so that future requests for that data can
|
> In computing, a cache is a hardware or software component that stores data so that future requests for that data can
|
||||||
> be served faster; the data stored in a cache might be the result of an earlier computation or a copy of data stored
|
> be served faster; the data stored in a cache might be the result of an earlier computation or a copy of data stored
|
||||||
> elsewhere. A cache hit occurs when the requested data can be found in a cache, while a cache miss occurs when it cannot.
|
> elsewhere. A cache hit occurs when the requested data can be found in a cache, while a cache miss occurs when it
|
||||||
> Cache hits are served by reading data from the cache, which is faster than recomputing a result or reading from a slower
|
> cannot. Cache hits are served by reading data from the cache, which is faster than recomputing a result or reading
|
||||||
> data store; thus, the more requests that can be served from the cache, the faster the system performs.
|
> from a slower data store; thus, the more requests that can be served from the cache, the faster the system performs.
|
||||||
|
|
||||||
**Programmatic Example**
|
**Programmatic Example**
|
||||||
|
|
||||||
|
|||||||
@@ -28,10 +28,9 @@ Real world example
|
|||||||
> services is slow or not responding successfully, our application will try to fetch response from
|
> services is slow or not responding successfully, our application will try to fetch response from
|
||||||
> the remote service using multiple threads/processes, soon all of them will hang (also called
|
> the remote service using multiple threads/processes, soon all of them will hang (also called
|
||||||
> [thread starvation](https://en.wikipedia.org/wiki/Starvation_(computer_science))) causing our entire web application
|
> [thread starvation](https://en.wikipedia.org/wiki/Starvation_(computer_science))) causing our entire web application
|
||||||
> to crash. We should be able to detect
|
> to crash. We should be able to detect this situation and show the user an appropriate message so that he/she can
|
||||||
> this situation and show the user an appropriate message so that he/she can explore other parts of
|
> explore other parts of the app unaffected by the remote serv'ice failure. Meanwhile, the other services that are
|
||||||
> the app unaffected by the remote service failure. Meanwhile, the other services that are working
|
> working normally, should keep functioning unaffected by this failure.
|
||||||
> normally, should keep functioning unaffected by this failure.
|
|
||||||
|
|
||||||
In plain words
|
In plain words
|
||||||
|
|
||||||
|
|||||||
@@ -21,17 +21,17 @@ application, ensuring a continuous and personalized user experience.
|
|||||||
Real-World Example
|
Real-World Example
|
||||||
|
|
||||||
> You're looking to create a data management app allowing users to send requests to the server to modify and make
|
> You're looking to create a data management app allowing users to send requests to the server to modify and make
|
||||||
> changes to data stored on their devices. These requests are small and the data is individual to each user, negating the
|
> changes to data stored on their devices. These requests are small and the data is individual to each user, negating
|
||||||
> need for a large scale database implementation. Using the client session pattern, you are able to handle multiple
|
> the need for a large scale database implementation. Using the client session pattern, you are able to handle multiple
|
||||||
> concurrent requests, load balancing clients across different servers with ease due to servers remaining stateless. You
|
> concurrent requests, load balancing clients across different servers with ease due to servers remaining stateless. You
|
||||||
> also remove the need to store session IDs on the server side due to clients providing all the information that a server
|
> also remove the need to store session IDs on the server side due to clients providing all the information that a
|
||||||
> needs to perform their process.
|
> server needs to perform their process.
|
||||||
|
|
||||||
In Plain words
|
In Plain words
|
||||||
|
|
||||||
> Instead of storing information about the current client and the information being accessed on the server, it is
|
> Instead of storing information about the current client and the information being accessed on the server, it is
|
||||||
> maintained client side only. Client has to send session data with each request to the server and has to send an updated
|
> maintained client side only. Client has to send session data with each request to the server and has to send an
|
||||||
> state back to the client, which is stored on the clients machine. The server doesn't have to store the client
|
> updated state back to the client, which is stored on the clients machine. The server doesn't have to store the client
|
||||||
> information. ([ref](https://dzone.com/articles/practical-php-patterns/practical-php-patterns-client))
|
> information. ([ref](https://dzone.com/articles/practical-php-patterns/practical-php-patterns-client))
|
||||||
|
|
||||||
**Programmatic Example**
|
**Programmatic Example**
|
||||||
|
|||||||
@@ -105,7 +105,8 @@ public class App {
|
|||||||
*/
|
*/
|
||||||
for (PrinterItem nextItem : printerQueue.getPrinterQueue()) {
|
for (PrinterItem nextItem : printerQueue.getPrinterQueue()) {
|
||||||
if (nextItem.paperSize.equals(PaperSizes.A4)) {
|
if (nextItem.paperSize.equals(PaperSizes.A4)) {
|
||||||
var isColouredAndSingleSided = nextItem.isColour && !nextItem.isDoubleSided;
|
var isColouredAndSingleSided =
|
||||||
|
nextItem.isColour && !nextItem.isDoubleSided;
|
||||||
if (isColouredAndSingleSided) {
|
if (isColouredAndSingleSided) {
|
||||||
printerItemsCollection.add(nextItem);
|
printerItemsCollection.add(nextItem);
|
||||||
} else if (!nextItem.isColour) {
|
} else if (!nextItem.isColour) {
|
||||||
@@ -127,7 +128,8 @@ public class App {
|
|||||||
if (nextItem.paperSize.equals(PaperSizes.A3)) {
|
if (nextItem.paperSize.equals(PaperSizes.A3)) {
|
||||||
|
|
||||||
// Encoding the policy into a Boolean: the A3 paper cannot be coloured and double-sided at the same time
|
// Encoding the policy into a Boolean: the A3 paper cannot be coloured and double-sided at the same time
|
||||||
var isNotColouredAndSingleSided = !nextItem.isColour && !nextItem.isDoubleSided;
|
var isNotColouredAndSingleSided =
|
||||||
|
!nextItem.isColour && !nextItem.isDoubleSided;
|
||||||
if (isNotColouredAndSingleSided) {
|
if (isNotColouredAndSingleSided) {
|
||||||
printerItemsCollection.add(nextItem);
|
printerItemsCollection.add(nextItem);
|
||||||
}
|
}
|
||||||
@@ -147,7 +149,9 @@ public class App {
|
|||||||
if (nextItem.paperSize.equals(PaperSizes.A2)) {
|
if (nextItem.paperSize.equals(PaperSizes.A2)) {
|
||||||
|
|
||||||
// Encoding the policy into a Boolean: the A2 paper must be single page, single-sided, and non-coloured.
|
// Encoding the policy into a Boolean: the A2 paper must be single page, single-sided, and non-coloured.
|
||||||
var isNotColouredSingleSidedAndOnePage = nextItem.pageCount == 1 && !nextItem.isDoubleSided
|
var isNotColouredSingleSidedAndOnePage =
|
||||||
|
nextItem.pageCount == 1 &&
|
||||||
|
!nextItem.isDoubleSided
|
||||||
&& !nextItem.isColour;
|
&& !nextItem.isColour;
|
||||||
if (isNotColouredSingleSidedAndOnePage) {
|
if (isNotColouredSingleSidedAndOnePage) {
|
||||||
printerItemsCollection.add(nextItem);
|
printerItemsCollection.add(nextItem);
|
||||||
|
|||||||
Reference in new issue
Block a user