アプリ関連ニュース
新しいiPhone12シリーズについて
tanaka at 2020年10月21日 10:00:15
- 2020年10月19日
- 技術情報
Bridge Design Pattern
Bridge is a structural design pattern that allows you to divide a large class or a set of closely related classes into two separate hierarchies (abstraction and implementation) that can be developed independently of each other.
Bridge is a synonym for the expression “handle / body”. This is a design mechanism that encapsulates an implementation class within an interface class. The first is the body and the second is the handle. The user sees the identifier as the actual class, but the work is done in the body. “The idiom for the handle / body class can be used to decompose a complex abstraction into smaller, more manageable classes. The idiom can reflect the sharing of a single resource by multiple classes that control access to it (for example, the count of references)”.
- Decouple an abstraction from your implementation so that the two can vary independently.
- Publish the interface in an inheritance hierarchy and hide the implementation in its own inheritance hierarchy.
Lets take a look at the code samples I created as below.
PHP Code Sample
<?php
/**
* This is the original application interface
* where we place the methods need to develop from its concrete sub classes
*/
interface ApplicationInterface
{
public function setDbDriver(DbDriver $dbDriver);
public function query($query);
}
/**
* This abstract class will implements the interface as we have to reference the next hierarchy object here.
* After that we can access the methods of their sub concrete classes in our sub classes. see below.
*/
abstract class Application implements ApplicationInterface
{
protected $dbDriver;
public function setDbDriver(DbDriver $dbDriver)
{
$this->dbDriver = $dbDriver;
}
}
/**
* Concrete sub classes of the original class working with the reference object's method.
*/
class android extends Application
{
public function query($query)
{
$query .= "\n\n running android app query\n";
return $this->dbDriver->handleQuery($query);
}
}
class ios extends Application
{
public function query($query)
{
$query .= "\n\n running ios app query\n";
return $this->dbDriver->handleQuery($query);
}
}
/**
* This is the interface that need to be referenced by original class instead of inheritance.
*/
interface DbDriver
{
public function handleQuery($query);
}
/**
* Concrete classes that will have the detail implementations of the interface.
*/
class MysqlDriver implements DbDriver
{
public function handleQuery($query)
{
echo "\nUsing the mysql driver: ".$query;
}
}
class OracleDriver implements DbDriver
{
public function handleQuery($query)
{
echo "\nUsing the oracle driver: ".$query;
}
}
//client code
// client doesn't need to know any implementation details.
// Just build the original concrete class and inject the concrete object that will be referenced.
$android = new android();
$android->setDbDriver(new MysqlDriver());
echo $android->query("select * from table");
$android->setDbDriver(new OracleDriver());
echo $android->query("select * from table");
$ios = new ios();
$ios->setDbDriver(new MysqlDriver());
echo $ios->query("select * from table");
$ios->setDbDriver(new OracleDriver());
echo $ios->query("select * from table");
C# Code Sample
using System;
using System.Collections.Generic;
namespace HelloWorld
{
/**
* Two Original classes referencing the same DbDriver which is the next hierarchy object
* After that we can access the methods of their sub concrete classes in our sub classes. query method in this case
*/
class ApplicationInterface
{
protected DbDriver _dbdriver;
public ApplicationInterface(DbDriver dbdriver)
{
this._dbdriver = dbdriver;
}
public virtual string setDbDriver()
{
return "Base DB Driver:" +
_dbdriver.query();
}
}
class RefinedAbstraction : ApplicationInterface
{
public RefinedAbstraction(DbDriver dbdriver) : base(dbdriver)
{
}
public override string setDbDriver()
{
return "Refined DB Driver:" +
base._dbdriver.query();
}
}
/**
* This is the interface that need to be referenced by original class instead of inheritance.
*/
public interface DbDriver
{
string query();
}
/**
* Concrete classes that will have the detail implementations of the interface.
*/
class MysqlDriver : DbDriver
{
public string query()
{
return "Using the mysql driver:\n";
}
}
class OracleDriver : DbDriver
{
public string query()
{
return "Using the oracle driver:.\n";
}
}
// client doesn't need to know any implementation details.
// Just build the original class and inject the concrete object that will be referenced.
class Client
{
public void ClientCode(ApplicationInterface applicationInterface)
{
Console.Write(applicationInterface.setDbDriver());
}
}
class Program
{
static void Main(string[] args)
{
Client client = new Client();
ApplicationInterface applicationInterface;
applicationInterface = new ApplicationInterface(new MysqlDriver());
client.ClientCode(applicationInterface);
Console.WriteLine();
applicationInterface = new RefinedAbstraction(new OracleDriver());
client.ClientCode(applicationInterface);
}
}
}
yuuma at 2020年10月19日 11:00:17
- 2020年10月16日
- 技術情報
[Laravel] Passportを使用したBearer token認証[4]
今回はPHPのLaravelフレームワークのPassportを使用したBearer token認証の方法について紹介します。
本記事は前回の「[Laravel] Passportを使用したBearer token認証[3]]」の続きとなります。
今回は前回追加した認証テスト用ユーザーを使用してBearer tokenの発行と認証のテストをおこなっていきたいと思います。
nishida at 2020年10月16日 10:00:55
- 2020年10月14日
- 他の話題
AMDの新しいCPUについて
今月8日にAMDから次世代CPUシリーズの発表がありました。
発表前の噂通り現行のCPUシリーズと比べて約20%の性能向上があるようです。
主にPCゲーム実行時の性能向上が大きいようですね。
発売予定日は11月5日です。

今回発表されたCPUシリーズは
Ryzen 5 5600XにのみCPUクーラーが付属し、
Ryzen 7 5800X以上の製品にはCPUクーラーが付属しないようです。
現行シリーズのRyzen 9 3900X 以下のCPUに
これまで付属していたWraithシリーズのCPUクーラーでは
冷却性能不足になる程の発熱があるのでしょうか。
公開されている性能表上のTDPの値は変わっていないので
定格で使っている限りは使えなくはない気もしますが、
ブーストクロック数が増えているので最大発熱量が
増えているのでしょう。
個人的にはCPUの性能向上よりも、新しいチップセットで
Thunderbolt(あるいはUSB4)がサポートされるかどうかが
気になっていたのですが、今回の発表ではチップセットに関する
情報は無かったようです。
11月に入れば チップセット の情報も公開されるでしょう。
そのかわり、Radeon RX6000 シリーズに関する発表が少しだけありました。
Radeon RX6000 シリーズは、
4K解像度のPCゲームでも60fps以上を実現できる性能のようです。
Ryzen 7 5800X が4万円~5万円台前半で買えるのであれば買いたいですね。
水曜担当:Tanaka
tanaka at 2020年10月14日 10:00:52
- 2020年10月12日
- 技術情報
Builder Design Pattern
Builder is a creative design pattern that allows you to build complex objects step by step. The pattern allows you to produce different types and representations of an object using the same building code.
Imagine a complex object that requires laborious step-by-step initialization of many nested objects and fields. This initialization code is usually buried inside a monster constructor with many parameters. Or even worse: scattered throughout the client code.
The Builder pattern suggests that you extract the object construction code out of its own class and move it to separate objects called builders.
Lets look up the code examples I wrote as below.
PHP Code Sample
<?php
/**
* This is the original application interface
* where we place the methods need to develop from its concrete sub classes
*/
interface ApplicationInterface
{
public function setDbDriver(DbDriver $dbDriver);
public function query($query);
}
/**
* This abstract class will implements the interface as we have to reference the next hierarchy object here.
* After that we can access the methods of their sub concrete classes in our sub classes. see below.
*/
abstract class Application implements ApplicationInterface
{
protected $dbDriver;
public function setDbDriver(DbDriver $dbDriver)
{
$this->dbDriver = $dbDriver;
}
}
/**
* Concrete sub classes of the original class working with the reference object's method.
*/
class android extends Application
{
public function query($query)
{
$query .= "\n\n running android app query\n";
return $this->dbDriver->handleQuery($query);
}
}
class ios extends Application
{
public function query($query)
{
$query .= "\n\n running ios app query\n";
return $this->dbDriver->handleQuery($query);
}
}
/**
* This is the interface that need to be referenced by original class instead of inheritance.
*/
interface DbDriver
{
public function handleQuery($query);
}
/**
* Concrete classes that will have the detail implementations of the interface.
*/
class MysqlDriver implements DbDriver
{
public function handleQuery($query)
{
echo "\nUsing the mysql driver: ".$query;
}
}
class OracleDriver implements DbDriver
{
public function handleQuery($query)
{
echo "\nUsing the oracle driver: ".$query;
}
}
//client code
// client doesn't need to know any implementation details.
// Just build the original concrete class and inject the concrete object that will be referenced.
$android = new android();
$android->setDbDriver(new MysqlDriver());
echo $android->query("select * from table");
$android->setDbDriver(new OracleDriver());
echo $android->query("select * from table");
$ios = new ios();
$ios->setDbDriver(new MysqlDriver());
echo $ios->query("select * from table");
$ios->setDbDriver(new OracleDriver());
echo $ios->query("select * from table");
C# Code Sample
using System;
using System.Collections.Generic;
namespace HelloWorld
{
/**
* Two Original classes referencing the same DbDriver which is the next hierarchy object
* After that we can access the methods of their sub concrete classes in our sub classes. query method in this case
*/
class ApplicationInterface
{
protected DbDriver _dbdriver;
public ApplicationInterface(DbDriver dbdriver)
{
this._dbdriver = dbdriver;
}
public virtual string setDbDriver()
{
return "Base DB Driver:" +
_dbdriver.query();
}
}
class RefinedAbstraction : ApplicationInterface
{
public RefinedAbstraction(DbDriver dbdriver) : base(dbdriver)
{
}
public override string setDbDriver()
{
return "Refined DB Driver:" +
base._dbdriver.query();
}
}
/**
* This is the interface that need to be referenced by original class instead of inheritance.
*/
public interface DbDriver
{
string query();
}
/**
* Concrete classes that will have the detail implementations of the interface.
*/
class MysqlDriver : DbDriver
{
public string query()
{
return "Using the mysql driver:\n";
}
}
class OracleDriver : DbDriver
{
public string query()
{
return "Using the oracle driver:.\n";
}
}
// client doesn't need to know any implementation details.
// Just build the original class and inject the concrete object that will be referenced.
class Client
{
public void ClientCode(ApplicationInterface applicationInterface)
{
Console.Write(applicationInterface.setDbDriver());
}
}
class Program
{
static void Main(string[] args)
{
Client client = new Client();
ApplicationInterface applicationInterface;
applicationInterface = new ApplicationInterface(new MysqlDriver());
client.ClientCode(applicationInterface);
Console.WriteLine();
applicationInterface = new RefinedAbstraction(new OracleDriver());
client.ClientCode(applicationInterface);
}
}
}
By Yuuma
yuuma at 2020年10月12日 11:00:33