제어 반전

제어 반전, 제어의 반전, 역제어는 프로그래머가 작성한 프로그램이 재사용 라이브러리의 흐름 제어를 받게 되는 소프트웨어 디자인 패턴을 말한다. 줄여서 IoC(Inversion of Control)이라고 부른다. 전통적인 프로그래밍에서 흐름은 프로그래머가 작성한 프로그램이 외부 라이브러리의 코드를 호출해 이용한다. 하지만 제어 반전이 적용된 구조에서는 외부 라이브러리의 코드가 프로그래머가 작성한 코드를 호출한다. 설계 목적상 제어 반전의 목적은 다음과 같다:

  • 작업을 구현하는 방식과 작업 수행 자체를 분리한다.
  • 모듈을 제작할 때, 모듈과 외부 프로그램의 결합에 대해 고민할 필요 없이 모듈의 목적에 집중할 수 있다.
  • 다른 시스템이 어떻게 동작할지에 대해 고민할 필요 없이, 미리 정해진 협약대로만 동작하게 하면 된다.
  • 모듈을 바꾸어도 다른 시스템에 부작용을 일으키지 않는다.

public class ServerFacade
{
  public Object respondToRequest(Object pRequest)
  {
    if(businessLayer.validateRequest(pRequest))
    {
      DAO.getData(pRequest);
      return Aspect.convertData(pRequest);
    }

    return null;
  }
}

위의 코드를 통해 IoC가 어떻게 이용되는지를 알 수 있다. 위에서 serverFacade에서 DAO 객체를 이용할 때 businessLayer객체가 pRequest를 검증하는 방법과 Aspect 객체가 DAO에서 처리한 pRequest를 변환하는 방법이 미리 정해져 있다. 이와 같이 정해진 방법들이 유효할 때도 있겠지만, 이 방법들을 정해 두면 serverFacade 클래스는 DAO와 결합되게 된다. 제어 반전 개념으로 다음과 같이 응용 프로그램을 설계하면 제어권을 완전히 DAO 객체로 이양하게 된다.

public class ServerFacade
{
  public Object respondToRequest(Object pRequest, DAO dao)
  {
    return dao.getData(pRequest);
  }
}

이 예를 보면, respondToRequest라는 메서드가 인자들을 다루는 방식을 통해 IoC가 적용되었는지 여부를 확인할 수 있다.

같이 보기

외부 링크

Read other articles:

Alex KendrickPembuat film Alex Kendrick pada 2019Lahir11 Juni 1970[1]Athens, GeorgiaTempat tinggalAlbany, GeorgiaKebangsaanAmerika SerikatPekerjaansutradara, produser, pemeran filmTahun aktif2003-sekarangKarya terkenalWar RoomSuami/istriChristina KendrickAnak6Situs webKendrick Brothers Productions Alex Kendrick (lahir tahun 11 juni 1970) adalah seorang penulis film, sutradara, produser, dan aktor asal Amerika Serikat..[2] Dari tahun 1999 sampai 2014, ia menjabat sebagai ...

 

Artikel ini sebatang kara, artinya tidak ada artikel lain yang memiliki pranala balik ke halaman ini.Bantulah menambah pranala ke artikel ini dari artikel yang berhubungan atau coba peralatan pencari pranala.Tag ini diberikan pada November 2022. Henri RollanLahir(1888-03-23)23 Maret 1888Paris, PrancisMeninggal23 Juni 1967(1967-06-23) (umur 79)Paris, PrancisPekerjaanPemeranTahun aktif1910-1962 Henri Rollan (23 Maret 1888 – 23 Juni 1967) adalah seorang pemeran film Pra...

 

Эфиопские евреи Современное самоназвание ивр. ‏בֵּיתֶא יִשְׂרָאֵל‏‎‎ Численность 136 тыс. чел. Расселение  Израиль — 130,5 тыс. чел  Эфиопия — по разным оценкам 1,9 тыс. чел.[1], 5 тыс. чел.[2][3], 6 тыс. чел.[4] или 9 тыс. чел.[5][6] США — 1 тыс. чел...

Integral takwajar jenis pertama. Integral perlu didefiniskan pada domain yang tak berbatas (batas adalah takhingga) Integral takwajar jenis kedua. Integral mungkin tidak ada karena adanya asimtot tegaklurus pada fungsi tersebut Kalkulus Teorema dasar Limit fungsi Kontinuitas Teorema nilai purata Teorema Rolle Diferensial Definisi Turunan (perumuman) Tabel turunan Diferensial infinitesimal fungsi total Konsep Notasi untuk pendiferensialan Turunan kedua Turunan ketiga Perubahan variabel Pe...

 

Charles GoodyearCharles Goodyear sebagaimana diilustrasikan pada sebuah artikel Scientific American pada tahun 1981.Lahir29 Desember 1800New Haven, ConnecticutMeninggal1 Juli 1860(1860-07-01) (umur 59)KebangsaanAmerika SerikatAnakEllen M.P. Goodyear (putri)Cynthia Goodyear (putri)Charles Goodyear, Jr. (putra)Amelia P. Goodyear (putri)Ann Goodyear (putri)William Henry Goodyear (putra) Charles Goodyear (29 Desember 1800 – 1 Juli 1860) adalah seorang berkebangsaan Amerika S...

 

Paul ButlerButler in 1956Chair of the Democratic National CommitteeIn office1955–1960Preceded byStephen MitchellSucceeded byHenry M. Jackson Personal detailsBornPaul Mulholland Butler(1905-06-15)June 15, 1905South Bend, Indiana, U.S.DiedDecember 30, 1961(1961-12-30) (aged 56)Washington, D.C., U.S.Political partyDemocraticEducationUniversity of Notre Dame (LLB) Paul Mulholland Butler (1905–1961)[1] was an American lawyer who served as the chairman of the Democratic National Co...

United States National Wildlife Refuge Ellicott Slough National Wildlife RefugeIUCN category IV (habitat/species management area)Calabasas PondMap of the United StatesLocationSanta Cruz County, California, United StatesNearest cityWatsonville, CaliforniaCoordinates36°55′36″N 121°50′17″W / 36.92661°N 121.838°W / 36.92661; -121.838[1]Area168 acres (0.68 km2)Established1975Governing bodyU.S. Fish and Wildlife ServiceWebsiteEllicott Sloug...

 

Digestive system structure This article is one of a series on theGastrointestinal wall General structure Epithelium Mucosa Submucosa Circular muscle Longitudinal muscle Serosa Adventitia Specific Meissner's plexus Auerbach's plexus Organs Esophagus Stomach Intestines vte The gastrointestinal wall of the gastrointestinal tract is made up of four layers of specialised tissue. From the inner cavity of the gut (the lumen) outwards, these are: Mucosa Submucosa Muscular layer Serosa or adventitia T...

 

Presidential transition of Jimmy CarterPresident-elect Carter meets with outgoing President Gerald Ford in the Oval Office as part of the transitionDate of electionNovember 2, 1976Transition startNovember 3, 1976Inauguration dateJanuary 20, 1977President-electJimmy Carter (Democrat)Vice president-electWalter Mondale (Democrat)Outgoing presidentGerald Ford (Republican)Outgoing vice presidentNelson Rockefeller (Republican)HeadquartersPlains, GeorgiaDirectorJack Watson This article or section is...

Untuk kegunaan lain, lihat Get Married (disambiguasi). Get M4rriedPoster filmSutradaraMonty TiwaProduserChand Parwez ServiaFiaz ServiaDitulis olehCassandra MassardiPemeranNirina ZubirTatjana SaphiraNino FernandezAmingRinggo Agus RahmanAlfie AlfandyDeddy Mahendra DestaIra WibowoJaja MihardjaMeriam BellinaRicky HarunMath Wang KieNaratorArie DagienkzPenata musikSlankSinematograferRollie MarkianoPenyuntingRyan PurwokoOliver SitompulCesa David LuckmansyahPerusahaanproduksiStarvisionTanggal r...

 

Loss of consciousness caused by cerebral hypoxia towards the end of a breath-hold dive Freediving blackout, breath-hold blackout,[1] or apnea blackout is a class of hypoxic blackout, a loss of consciousness caused by cerebral hypoxia towards the end of a breath-hold (freedive or dynamic apnea) dive, when the swimmer does not necessarily experience an urgent need to breathe and has no other obvious medical condition that might have caused it. It can be provoked by hyperventilating jus...

 

Social movement in South Africa This article is about the social movement in South Africa. For the political party in Namibia, see Landless People's Movement (Namibia). The Landless People's Movement outside the Constitutional Court, 14 May 2009 The Landless People's Movement is an independent social movement in South Africa. It consisted of rural people and people living in shack settlements in cities.[1] The Landless People's Movement boycotted parliamentary elections[2] and...

Robledillo de Gatacomune Robledillo de Gata – Veduta LocalizzazioneStato Spagna Comunità autonoma Estremadura Provincia Cáceres TerritorioCoordinate40°19′00.12″N 6°28′00.12″W / 40.3167°N 6.4667°W40.3167; -6.4667 (Robledillo de Gata)Coordinate: 40°19′00.12″N 6°28′00.12″W / 40.3167°N 6.4667°W40.3167; -6.4667 (Robledillo de Gata) Altitudine576 m s.l.m. Superficie31 km² Abitanti144 (2001) Densità4,65 ab...

 

American utility company NextEra Energy, Inc.FormerlyFPL GroupCompany typePublicTraded asNYSE: NEEDJUA componentS&P 100 componentS&P 500 componentIndustryElectric power industryEnergy developmentRenewable energyFounded1984; 40 years ago (1984) as FPL GroupHeadquartersJuno Beach, Florida, U.S.Area servedUnited States and CanadaKey peopleJohn W. Ketchum (Chairman, President and CEO of NEE)Armando Pimentel Jr. (President and CEO of FPL)Rebecca J. Kujawa (President ...

 

2016年美國總統選舉 ← 2012 2016年11月8日 2020 → 538個選舉人團席位獲勝需270票民意調查投票率55.7%[1][2] ▲ 0.8 %   获提名人 唐納·川普 希拉莉·克林頓 政党 共和黨 民主党 家鄉州 紐約州 紐約州 竞选搭档 迈克·彭斯 蒂姆·凱恩 选举人票 304[3][4][註 1] 227[5] 胜出州/省 30 + 緬-2 20 + DC 民選得票 62,984,828[6] 65,853,514[6]...

1900年美國總統選舉 ← 1896 1900年11月6日 1904 → 447張選舉人票獲勝需224張選舉人票投票率73.2%[1] ▼ 6.1 %   获提名人 威廉·麥金利 威廉·詹寧斯·布賴恩 政党 共和黨 民主党 家鄉州 俄亥俄州 內布拉斯加州 竞选搭档 西奧多·羅斯福 阿德萊·史蒂文森一世 选举人票 292 155 胜出州/省 28 17 民選得票 7,228,864 6,370,932 得票率 51.6% 45.5% 總統選舉結果地圖,紅色代表�...

 

فتحي زهير عميد المحامين التونسيين في المنصبيوليو 1975 – 1977 محمد بن للونة الأزهر القروي الشابي رئيس الجامعة التونسية لكرة القدم في المنصب1971 – 1971 أحمد زويتن الهادي العنابي نائب في مجلس الأمة التونسي في المنصب1969 – 1974 تاريخ الانتخاب انتخابات 2 نوفمبر 1969 رئيس النادي الإفريقي ف�...

 

Pour les articles homonymes, voir Bouquet. Bouquet Blason Administration Pays France Région Occitanie Département Gard Arrondissement Nîmes Intercommunalité Communauté de communes Pays d'Uzès Maire Mandat Catherine Ferrière 2020-2026 Code postal 30580 Code commune 30048 Démographie Gentilé Bouquentencs Populationmunicipale 190 hab. (2021 ) Densité 6,3 hab./km2 Géographie Coordonnées 44° 09′ 36″ nord, 4° 17′ 27″ est Altitude Min. 1...

Soft inner wool of the muskox A small piece of qiviut wool Qiviuq [sg] or qiviut [pl] (/ˈkɪviət/ KIV-ee-ət; Inuktitut syllabics: ᕿᕕᐅᖅ; Inuinnaqtun: qiviuq;[1] Inupiaq: qiviu or qiviuq[2] (sometimes spelled qiveut)) is the inner wool of the muskox. In Inuinnaqtun the same word can be used to refer any down such as the down feathers of birds.[1] The muskox has a two-layered coat, and qiviut refers specifically to the soft underwool beneath the longer outer wo...

 

Fleet of Spanish ships, intended to attack England in 1596 2nd Spanish ArmadaPart of the Anglo-Spanish WarPhilip II of Spain in his old age, ordered the Armada of 1596 in revenge for the English attack on CadizDate24 October – 1 November 1596LocationCape Finisterre, AtlanticResult English victory[1][2][3]Belligerents Spain EnglandCommanders and leaders Philip II Martín de Padilla Diego Brochero Sancho Martínez de Leyva Carlos de Arellano Elizabeth I Robert Devereux...