-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
İbrahim Atay
committed
Dec 23, 2024
0 parents
commit 542fd16
Showing
62 changed files
with
2,338 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# For most projects, this workflow file will not need changing; you simply need | ||
# to commit it to your repository. | ||
# | ||
# You may wish to alter this file to override the set of languages analyzed, | ||
# or to provide custom queries or build logic. | ||
# | ||
# ******** NOTE ******** | ||
# We have attempted to detect the languages in your repository. Please check | ||
# the `language` matrix defined below to confirm you have the correct set of | ||
# supported CodeQL languages. | ||
# | ||
name: "CodeQL" | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
schedule: | ||
- cron: '31 2 * * 4' | ||
|
||
jobs: | ||
analyze: | ||
name: Analyze (${{ matrix.language }}) | ||
# Runner size impacts CodeQL analysis time. To learn more, please see: | ||
# - https://gh.io/recommended-hardware-resources-for-running-codeql | ||
# - https://gh.io/supported-runners-and-hardware-resources | ||
# - https://gh.io/using-larger-runners (GitHub.com only) | ||
# Consider using larger runners or machines with greater resources for possible analysis time improvements. | ||
runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} | ||
timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} | ||
permissions: | ||
# required for all workflows | ||
security-events: write | ||
|
||
# only required for workflows in private repositories | ||
actions: read | ||
contents: read | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- language: csharp | ||
build-mode: autobuild | ||
- language: java-kotlin | ||
build-mode: none # This mode only analyzes Java. Set this to 'autobuild' or 'manual' to analyze Kotlin too. | ||
# CodeQL supports the following values keywords for 'language': 'c-cpp', 'csharp', 'go', 'java-kotlin', 'javascript-typescript', 'python', 'ruby', 'swift' | ||
# Use `c-cpp` to analyze code written in C, C++ or both | ||
# Use 'java-kotlin' to analyze code written in Java, Kotlin or both | ||
# Use 'javascript-typescript' to analyze code written in JavaScript, TypeScript or both | ||
# To learn more about changing the languages that are analyzed or customizing the build mode for your analysis, | ||
# see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/customizing-your-advanced-setup-for-code-scanning. | ||
# If you are analyzing a compiled language, you can modify the 'build-mode' for that language to customize how | ||
# your codebase is analyzed, see https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
# Initializes the CodeQL tools for scanning. | ||
- name: Initialize CodeQL | ||
uses: github/codeql-action/init@v3 | ||
with: | ||
languages: ${{ matrix.language }} | ||
build-mode: ${{ matrix.build-mode }} | ||
# If you wish to specify custom queries, you can do so here or in a config file. | ||
# By default, queries listed here will override any specified in a config file. | ||
# Prefix the list here with "+" to use these queries and those in the config file. | ||
|
||
# For more details on CodeQL's query packs, refer to: https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs | ||
# queries: security-extended,security-and-quality | ||
|
||
# If the analyze step fails for one of the languages you are analyzing with | ||
# "We were unable to automatically build your code", modify the matrix above | ||
# to set the build mode to "manual" for that language. Then modify this step | ||
# to build your code. | ||
# ℹ️ Command-line programs to run using the OS shell. | ||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun | ||
- if: matrix.build-mode == 'manual' | ||
run: | | ||
echo 'If you are using a "manual" build mode for one or more of the' \ | ||
'languages you are analyzing, replace this with the commands to build' \ | ||
'your code, for example:' | ||
echo ' make bootstrap' | ||
echo ' make release' | ||
exit 1 | ||
- name: Perform CodeQL Analysis | ||
uses: github/codeql-action/analyze@v3 | ||
with: | ||
category: "/language:${{matrix.language}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven | ||
|
||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
name: Java CI with Maven | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
pull_request: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
- name: Build with Maven | ||
run: sh maven.sh | ||
|
||
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive | ||
- name: Update dependency graph | ||
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
.idea/* | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store | ||
======= | ||
# Compiled class file | ||
*.class | ||
|
||
# Log file | ||
*.log | ||
|
||
# BlueJ files | ||
*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
.mtj.tmp/ | ||
|
||
# Package Files # | ||
*.jar | ||
*.war | ||
*.nar | ||
*.ear | ||
*.zip | ||
*.tar.gz | ||
*.rar | ||
|
||
|
||
*.suo | ||
*.user | ||
.vs/ | ||
[Bb]in/ | ||
[Oo]bj/ | ||
_UpgradeReport_Files/ | ||
[Pp]ackages/ | ||
|
||
Thumbs.db | ||
Desktop.ini | ||
.DS_Store | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
hs_err_pid* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
[](https://github.com/ibrahimatay/Design-Patterns/actions/workflows/maven.yml) [](https://github.com/ibrahimatay/Design-Patterns/actions/workflows/dotnet.yml) | ||
# Design Patterns For Humans | ||
Examples of design patterns in Java and C# are presented in a way that is easy for humans to understand and implement. The purpose of these examples is to provide a practical and intuitive guide to the use of design patterns in Java, helping developers improve their skills and create more effective and maintainable software. | ||
|
||
 | ||
|
||
## ***Creational*** | ||
- Factory Method ([Java](/Java/factory-method), [C#](/Csharp/DesignPatterns.FactoryMethod)) | ||
- Abstract Factory ([Java](/Java/abstract-factory), [C#](/Csharp/DesignPatterns.AbstractFactory)) | ||
- Builder ([Java](/Java/builder), [C#](/Csharp/DesignPatterns.Builder)) | ||
- Prototype ([Java](/Java/prototype), [C#](/Csharp/DesignPatterns.Prototype)) | ||
- Singleton | ||
- Eager Instantiation ([Java](/Java/singleton-eager-instantiation), [C#](/Csharp/DesignPatterns.SingletonEagerInstantiation)) | ||
- Lazy Instantiation ([Java](/Java/singleton-lazy-instantiation), [C#](/Csharp/DesignPatterns.SingletonLazyInitialization)) | ||
- Enum-based Singleton ([Java](/Java/singleton-with-enum)) | ||
- Double-Checked Locking with Singleton ([C#](/Csharp/DesignPatterns.DoubleCheckedLockingwithSingleton/)) | ||
|
||
## ***Structural*** | ||
- Adapter ([Java](/Java/adapter), [C#](/Csharp/DesignPatterns.Adapter)) | ||
- Proxy ([Java](/Java/proxy), [C#](/Csharp/DesignPatterns.Proxy)) | ||
- Facade ([Java](/Java/facade), [C#](/Csharp/DesignPatterns.Facade)) | ||
- Composite ([Java](/Java/composite), [C#](/Csharp/DesignPatterns.Composite)) | ||
- Bridge ([Java](/Java/bridge), [C#](/Csharp/DesignPatterns.Bridge)) | ||
- Flyweight ([Java](/Java/flyweight), [C#](/Csharp/DesignPatterns.Flyweight)) | ||
- Decorator ([Java](/Java/decorator), [C#](/Csharp/DesignPatterns.Decorator)) | ||
|
||
## ***Behavioral*** | ||
- Command ([Java](/Java/command), [C#](/Csharp/DesignPatterns.Command)) | ||
- Iterator ([Java](/Java/iterator), [C#](/Csharp/DesignPatterns.Iterator)) | ||
- Memento ([Java](/Java/memento), [C#](/Csharp/DesignPatterns.Memento)) | ||
- Observer ([Java](/Java/observer) [C#](/Csharp/DesignPatterns.Observer)) | ||
- Strategy ([Java](/Java/strategy), [C#](/Csharp/DesignPatterns.Strategy)) | ||
- Template Method ([Java](/Java/template-method), [C#](/Csharp/DesignPatterns.TemplateMethod)) | ||
- Visitor ([Java](/Java/visitor), [C#](/Csharp/DesignPatterns.Visitor)) | ||
- Chain of Responsibility ([Java](/Java/chain-of-responsibility), [C#](/Csharp/DesignPatterns.ChainOfResponsibility)) | ||
- Pipeline ([Java](/Java/pipeline), [C#](/Csharp/DesignPatterns.Pipeline)) | ||
- State ([Java](/Java/state), [C#](/Csharp/DesignPatterns.State)) | ||
- Mediator ([Java](/Java/mediator), [C#](/Csharp/DesignPatterns.Mediator)) | ||
|
||
## References | ||
Design patterns in this repository are based on | ||
|
||
* [Design Patterns by The "Gang of Four"] | ||
* [Head First: Design Patterns] | ||
* [Wikipedia] | ||
* [Other Documents] | ||
|
||
[Design Patterns by The "Gang of Four"]: https://en.wikipedia.org/wiki/Design_Patterns | ||
[Head First: Design Patterns]: http://www.headfirstlabs.com/books/hfdp/ | ||
[Wikipedia]: https://en.wikipedia.org/wiki/Software_design_pattern | ||
[Other Documents]: docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>design-patterns</artifactId> | ||
<groupId>com.ibrahimatay</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>abstract-factory</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>${java.source.version}</maven.compiler.source> | ||
<maven.compiler.target>${java.target.version}</maven.compiler.target> | ||
</properties> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.ibrahimatay; | ||
|
||
interface Command { | ||
void execute(String query); | ||
} | ||
|
||
interface Connection { | ||
void connect(); | ||
void disconnect(); | ||
} | ||
|
||
interface DatabaseFactory { | ||
Connection createConnection(); | ||
Command createCommand(Connection connection); | ||
} | ||
|
||
class Db2Command implements Command { | ||
@Override | ||
public void execute(String query) { | ||
System.out.println("Db2 query executed"); | ||
} | ||
} | ||
|
||
class Db2Connection implements Connection { | ||
|
||
@Override | ||
public void connect() { | ||
System.out.println("Connection is connected."); | ||
} | ||
|
||
@Override | ||
public void disconnect() { | ||
System.out.println("Connection is disconnected."); | ||
} | ||
} | ||
|
||
class Db2DatabaseFactory implements DatabaseFactory { | ||
|
||
@Override | ||
public Connection createConnection() { | ||
return new Db2Connection(); | ||
} | ||
|
||
@Override | ||
public Command createCommand(Connection connection) { | ||
if(connection == null) { | ||
throw new NullPointerException(); | ||
} | ||
return new Db2Command(); | ||
} | ||
} | ||
|
||
public class Main { | ||
public static void main(String[] args) { | ||
DatabaseFactory db2DatabaseFactory = new Db2DatabaseFactory(); | ||
Connection connection = db2DatabaseFactory.createConnection(); | ||
Command command = db2DatabaseFactory.createCommand(connection); | ||
|
||
connection.connect(); | ||
command.execute("select * from product"); | ||
connection.disconnect(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>design-patterns</artifactId> | ||
<groupId>com.ibrahimatay</groupId> | ||
<version>1.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>adapter</artifactId> | ||
|
||
<properties> | ||
<maven.compiler.source>${java.source.version}</maven.compiler.source> | ||
<maven.compiler.target>${java.target.version}</maven.compiler.target> | ||
</properties> | ||
|
||
</project> |
Oops, something went wrong.