Knowledge (XXG)

Class-based programming

Source 📝

36: 327:
of objects, then extend it to make a new class called a set class where the duplication of objects is eliminated. Now, a function that takes an object of the bag class may expect that adding two objects increases the size of a bag by two, yet if one passes an object of a set class, then adding two
572:
because a child class and a parent class inherit a person class but class-based languages mostly do not allow to change the kind of class of the object at runtime. For class-based languages, this restriction is essential in order to preserve unified view of the class to its users. The users should
577:
of the class. Such changes can be made by destroying the object and constructing another in its place. Polymorphism can be used to preserve the relevant interfaces even when such changes are done, because the objects are viewed as black box abstractions and accessed via object
223:
of the class, which is useful because it allows the implementation of a class of objects to be changed for aspects not exposed in the interface without impact to user code. The definitions of encapsulation focus on the grouping and packaging of related information
208:, with the addition of method pointers, member access control, and an implicit data member which locates instances of the class (i.e., objects of the class) in the class hierarchy (essential for runtime inheritance features). 820: 328:
objects may or may not increase the size of a bag by two. The problem arises precisely because subclassing implies subtyping even in the instances where the principle of subtyping, known as the
323:, have been criticized for mixing up implementations and interfaces—the essential principle in object-oriented programming. The critics say one might create a bag class that stores a 1567: 561:
Thus, normally one must distinguish subtyping and subclassing. Most current object-oriented languages distinguish subtyping and subclassing, however some approaches to design do not.
726: 790: 739: 457: 376: 889: 824: 553: 529: 505: 481: 424: 400: 1560: 719: 591: 164:
The most popular and developed model of OOP is a class-based model, instead of an object-based model. In this model, objects are entities that combine
243: 237: 144: 953: 53: 1553: 1303: 1165: 1660: 1650: 1309: 579: 184: 291:
The defining feature of inheritance is that both interface and implementation are inherited; if only interface is inherited, this is known as
1708: 1665: 1655: 1645: 712: 200:, of all objects of a specific type. An object must be explicitly created based on a class and an object thus created is considered to be an 1726: 1622: 1494: 1242: 189: 962: 100: 119: 72: 1637: 1334: 1014: 958: 201: 1617: 1194: 1067: 998: 933: 856: 79: 1697: 1612: 1372: 1135: 765: 617: 57: 582:. However, usually the value of object references referring to the object is changed, which causes effects to client code. 1627: 1150: 1140: 918: 329: 86: 1534: 1514: 1444: 1387: 1349: 1339: 1299: 1224: 1160: 1130: 1057: 1046: 943: 923: 898: 861: 644: 574: 220: 149: 1489: 1252: 1219: 1114: 1090: 1052: 1032: 928: 837: 815: 800: 633: 613: 565: 316: 300: 255: 225: 158: 140: 68: 1686: 1436: 1422: 1329: 1289: 1214: 1120: 1100: 967: 846: 780: 687: 46: 1529: 1294: 1204: 1184: 1170: 178: 154: 1509: 1469: 1412: 1344: 1082: 913: 166: 1519: 1499: 1440: 1427: 1407: 1234: 971: 875: 1479: 1454: 1448: 1392: 1354: 1042: 1037: 989: 884: 785: 757: 748: 1381: 1377: 1319: 1271: 841: 573:
not need to care whether one of the implementations of a method happens to cause changes that break the
292: 247: 1605: 1576: 1524: 1504: 1464: 1266: 1125: 994: 981: 735: 639: 267: 188:(unique existence among all other objects). The structure and behavior of an object are defined by a 93: 1459: 1397: 1209: 1189: 1175: 907: 775: 770: 1276: 1229: 1199: 1145: 1004: 903: 795: 704: 260: 216: 1600: 1595: 1432: 1324: 1179: 1155: 1095: 1062: 1024: 1009: 948: 433: 352: 278: 1314: 1246: 1110: 851: 324: 1364: 1238: 1104: 805: 284: 1416: 1072: 938: 538: 514: 490: 466: 409: 385: 337: 333: 312: 205: 1720: 1402: 600:
introduced the class abstraction, the canonical example of a class-based language is
1590: 569: 251: 1545: 1284: 621: 35: 665: 193: 265:
while if a child class can have more than one parent class, this is known as
601: 320: 273: 197: 17: 27:
Style of object-oriented programming where inheritance is based on classes
172: 597: 564:
Also, another common example is that a person object created from a
609: 157:, instead of inheritance occurring via the objects alone (compare 340:
formulated the principle succinctly in a 1994 paper as follows:
1549: 708: 258:. If a child class has only one parent class, this is known as 605: 29: 541: 517: 493: 469: 436: 412: 388: 355: 299:
Inheritance can also be done without classes, as in
1636: 1583: 1478: 1363: 1265: 1081: 1023: 980: 883: 874: 814: 756: 747: 60:. Unsourced material may be challenged and removed. 547: 523: 499: 475: 451: 418: 394: 370: 311:Class-based languages, or, to be more precise, 250:of existing classes: the existing class is the 666:"Subtyping, Subclassing, and Trouble with OOP" 1561: 720: 8: 1568: 1554: 1546: 880: 753: 727: 713: 705: 592:Category:Class-based programming languages 791:Programming in the large and in the small 540: 516: 492: 468: 435: 411: 387: 354: 204:of that class. An object is similar to a 120:Learn how and when to remove this message 656: 380:be a property provable about objects 7: 688:"A set cannot be a subtype of a bag" 58:adding citations to reliable sources 246:is done by defining new classes as 25: 219:prevents users from breaking the 1335:Partitioned global address space 34: 228:) rather than security issues. 45:needs additional citations for 1577:Types of programming languages 446: 440: 365: 359: 272:This organizes classes into a 1: 330:Liskov substitution principle 1709:Programming paradigms navbox 862:Uniform Function Call Syntax 645:Class (computer programming) 242:In class-based programming, 1727:Object-oriented programming 1330:Parallel programming models 1304:Concurrent constraint logic 634:Prototype-based programming 568:cannot become an object of 461:should be true for objects 301:prototype-based programming 288:(if multiple inheritance). 282:(if single inheritance) or 159:prototype-based programming 141:object-oriented programming 1743: 1423:Metalinguistic abstraction 1290:Automatic mutual exclusion 589: 235: 1295:Choreographic programming 254:and the new class is the 69:"Class-based programming" 1345:Relativistic programming 452:{\displaystyle \phi (y)} 371:{\displaystyle \phi (x)} 133:Class-based programming 1355:Structured concurrency 740:Comparison by language 559: 549: 525: 501: 477: 453: 420: 396: 372: 176:(i.e., procedures, or 1698:Programming languages 1320:Multitier programming 1136:Interface description 736:Programming paradigms 640:Programming paradigms 550: 526: 502: 478: 454: 421: 397: 373: 342: 293:interface inheritance 539: 515: 491: 467: 434: 410: 386: 353: 268:multiple inheritance 147:occurs via defining 54:improve this article 1460:Self-modifying code 1068:Probabilistic logic 999:Functional reactive 954:Expression-oriented 908:Partial application 686:Ducasse, Stéphane. 345:Subtype Requirement 319:is the only way of 135:, or more commonly 1373:Attribute-oriented 1146:List comprehension 1091:Algebraic modeling 904:Anonymous function 796:Design by contract 766:Jackson structures 545: 521: 497: 473: 449: 416: 392: 368: 261:single inheritance 1687:Computer language 1674: 1673: 1543: 1542: 1433:Program synthesis 1325:Organic computing 1261: 1260: 1166:Non-English-based 1141:Language-oriented 919:Purely functional 870: 869: 604:. Others include 586:Example languages 548:{\displaystyle T} 524:{\displaystyle S} 500:{\displaystyle S} 476:{\displaystyle y} 419:{\displaystyle T} 395:{\displaystyle x} 332:, does not hold. 137:class-orientation 130: 129: 122: 104: 16:(Redirected from 1734: 1713: 1707: 1702: 1696: 1691: 1685: 1570: 1563: 1556: 1547: 1445:by demonstration 1350:Service-oriented 1340:Process-oriented 1315:Macroprogramming 1300:Concurrent logic 1171:Page description 1161:Natural language 1131:Grammar-oriented 1058:Nondeterministic 1047:Constraint logic 949:Point-free style 944:Functional logic 881: 852:Immutable object 771:Block-structured 754: 729: 722: 715: 706: 699: 698: 696: 694: 683: 677: 676: 674: 672: 664:Kiselyov, Oleg. 661: 556: 554: 552: 551: 546: 533:is a subtype of 532: 530: 528: 527: 522: 508: 506: 504: 503: 498: 484: 482: 480: 479: 474: 460: 458: 456: 455: 450: 427: 425: 423: 422: 417: 403: 401: 399: 398: 393: 379: 377: 375: 374: 369: 139:, is a style of 125: 118: 114: 111: 105: 103: 62: 38: 30: 21: 1742: 1741: 1737: 1736: 1735: 1733: 1732: 1731: 1717: 1716: 1711: 1705: 1700: 1694: 1689: 1683: 1680: 1675: 1670: 1632: 1623:Very high-level 1579: 1574: 1544: 1539: 1481: 1474: 1365:Metaprogramming 1359: 1275: 1270: 1257: 1239:Graph rewriting 1077: 1053:Inductive logic 1033:Abductive logic 1019: 976: 939:Dependent types 887: 866: 838:Prototype-based 818: 816:Object-oriented 810: 806:Nested function 801:Invariant-based 743: 733: 703: 702: 692: 690: 685: 684: 680: 670: 668: 663: 662: 658: 653: 630: 594: 588: 537: 536: 534: 513: 512: 510: 489: 488: 486: 465: 464: 462: 432: 431: 429: 408: 407: 405: 384: 383: 381: 351: 350: 348: 313:typed languages 309: 240: 234: 214: 143:(OOP) in which 126: 115: 109: 106: 63: 61: 51: 39: 28: 23: 22: 15: 12: 11: 5: 1740: 1738: 1730: 1729: 1719: 1718: 1715: 1714: 1703: 1692: 1679: 1676: 1672: 1671: 1669: 1668: 1663: 1658: 1653: 1648: 1642: 1640: 1634: 1633: 1631: 1630: 1625: 1620: 1615: 1609: 1608: 1603: 1598: 1593: 1587: 1585: 1581: 1580: 1575: 1573: 1572: 1565: 1558: 1550: 1541: 1540: 1538: 1537: 1532: 1527: 1522: 1517: 1512: 1507: 1502: 1497: 1492: 1486: 1484: 1476: 1475: 1473: 1472: 1467: 1462: 1457: 1452: 1430: 1425: 1420: 1410: 1405: 1400: 1395: 1390: 1385: 1375: 1369: 1367: 1361: 1360: 1358: 1357: 1352: 1347: 1342: 1337: 1332: 1327: 1322: 1317: 1312: 1307: 1297: 1292: 1287: 1281: 1279: 1263: 1262: 1259: 1258: 1256: 1255: 1250: 1235:Transformation 1232: 1227: 1222: 1217: 1212: 1207: 1202: 1197: 1192: 1187: 1182: 1173: 1168: 1163: 1158: 1153: 1148: 1143: 1138: 1133: 1128: 1123: 1121:Differentiable 1118: 1108: 1101:Automata-based 1098: 1093: 1087: 1085: 1079: 1078: 1076: 1075: 1070: 1065: 1060: 1055: 1050: 1040: 1035: 1029: 1027: 1021: 1020: 1018: 1017: 1012: 1007: 1002: 992: 986: 984: 978: 977: 975: 974: 968:Function-level 965: 956: 951: 946: 941: 936: 931: 926: 921: 916: 911: 901: 895: 893: 878: 872: 871: 868: 867: 865: 864: 859: 854: 849: 844: 830: 828: 812: 811: 809: 808: 803: 798: 793: 788: 783: 781:Non-structured 778: 773: 768: 762: 760: 751: 745: 744: 734: 732: 731: 724: 717: 709: 701: 700: 678: 655: 654: 652: 649: 648: 647: 642: 637: 629: 626: 587: 584: 544: 520: 496: 472: 448: 445: 442: 439: 415: 391: 367: 364: 361: 358: 338:Jeannette Wing 334:Barbara Liskov 308: 305: 236:Main article: 233: 230: 213: 210: 170:(i.e., data), 128: 127: 42: 40: 33: 26: 24: 14: 13: 10: 9: 6: 4: 3: 2: 1739: 1728: 1725: 1724: 1722: 1710: 1704: 1699: 1693: 1688: 1682: 1681: 1677: 1667: 1664: 1662: 1659: 1657: 1654: 1652: 1649: 1647: 1644: 1643: 1641: 1639: 1635: 1629: 1626: 1624: 1621: 1619: 1616: 1614: 1611: 1610: 1607: 1604: 1602: 1599: 1597: 1594: 1592: 1589: 1588: 1586: 1582: 1578: 1571: 1566: 1564: 1559: 1557: 1552: 1551: 1548: 1536: 1533: 1531: 1528: 1526: 1523: 1521: 1518: 1516: 1513: 1511: 1508: 1506: 1505:Data-oriented 1503: 1501: 1498: 1496: 1493: 1491: 1488: 1487: 1485: 1483: 1477: 1471: 1468: 1466: 1463: 1461: 1458: 1456: 1453: 1450: 1446: 1442: 1438: 1434: 1431: 1429: 1426: 1424: 1421: 1418: 1414: 1411: 1409: 1406: 1404: 1403:Homoiconicity 1401: 1399: 1396: 1394: 1391: 1389: 1386: 1383: 1379: 1376: 1374: 1371: 1370: 1368: 1366: 1362: 1356: 1353: 1351: 1348: 1346: 1343: 1341: 1338: 1336: 1333: 1331: 1328: 1326: 1323: 1321: 1318: 1316: 1313: 1311: 1310:Concurrent OO 1308: 1305: 1301: 1298: 1296: 1293: 1291: 1288: 1286: 1283: 1282: 1280: 1278: 1273: 1268: 1264: 1254: 1251: 1248: 1244: 1240: 1236: 1233: 1231: 1228: 1226: 1223: 1221: 1218: 1216: 1213: 1211: 1208: 1206: 1205:Set-theoretic 1203: 1201: 1198: 1196: 1193: 1191: 1188: 1186: 1185:Probabilistic 1183: 1181: 1177: 1174: 1172: 1169: 1167: 1164: 1162: 1159: 1157: 1154: 1152: 1149: 1147: 1144: 1142: 1139: 1137: 1134: 1132: 1129: 1127: 1124: 1122: 1119: 1116: 1112: 1109: 1106: 1102: 1099: 1097: 1094: 1092: 1089: 1088: 1086: 1084: 1080: 1074: 1071: 1069: 1066: 1064: 1061: 1059: 1056: 1054: 1051: 1048: 1044: 1041: 1039: 1036: 1034: 1031: 1030: 1028: 1026: 1022: 1016: 1013: 1011: 1008: 1006: 1003: 1000: 996: 993: 991: 988: 987: 985: 983: 979: 973: 969: 966: 964: 963:Concatenative 960: 957: 955: 952: 950: 947: 945: 942: 940: 937: 935: 932: 930: 927: 925: 922: 920: 917: 915: 912: 909: 905: 902: 900: 897: 896: 894: 891: 886: 882: 879: 877: 873: 863: 860: 858: 855: 853: 850: 848: 845: 843: 839: 835: 832: 831: 829: 826: 822: 817: 813: 807: 804: 802: 799: 797: 794: 792: 789: 787: 784: 782: 779: 777: 774: 772: 769: 767: 764: 763: 761: 759: 755: 752: 750: 746: 741: 737: 730: 725: 723: 718: 716: 711: 710: 707: 689: 682: 679: 667: 660: 657: 650: 646: 643: 641: 638: 635: 632: 631: 627: 625: 623: 619: 615: 611: 607: 603: 599: 593: 585: 583: 581: 576: 571: 567: 562: 558: 542: 518: 494: 470: 443: 437: 413: 389: 362: 356: 346: 341: 339: 335: 331: 326: 322: 318: 314: 306: 304: 302: 298: 294: 289: 287: 286: 281: 280: 275: 271: 269: 264: 262: 257: 253: 249: 245: 239: 231: 229: 227: 222: 218: 217:Encapsulation 212:Encapsulation 211: 209: 207: 203: 199: 195: 192:, which is a 191: 187: 186: 181: 180: 175: 174: 169: 168: 162: 160: 156: 152: 151: 146: 142: 138: 134: 124: 121: 113: 110:February 2013 102: 99: 95: 92: 88: 85: 81: 78: 74: 71: –  70: 66: 65:Find sources: 59: 55: 49: 48: 43:This article 41: 37: 32: 31: 19: 1712:}} 1706:{{ 1701:}} 1695:{{ 1690:}} 1684:{{ 1510:Event-driven 914:Higher-order 842:Object-based 833: 691:. Retrieved 681: 669:. Retrieved 659: 595: 570:parent class 563: 560: 344: 343: 310: 296: 290: 283: 277: 266: 259: 252:parent class 241: 215: 183: 177: 171: 165: 163: 148: 136: 132: 131: 116: 107: 97: 90: 83: 76: 64: 52:Please help 47:verification 44: 1606:Interpreted 1520:Intentional 1500:Data-driven 1482:of concerns 1441:Inferential 1428:Multi-stage 1408:Interactive 1285:Actor-based 1272:distributed 1215:Stack-based 1015:Synchronous 972:Value-level 959:Applicative 876:Declarative 834:Class-based 622:Objective-C 566:child class 317:subclassing 276:, either a 256:child class 244:inheritance 238:Inheritance 232:Inheritance 145:inheritance 18:Class-based 1638:Generation 1618:High-level 1495:Components 1480:Separation 1455:Reflective 1449:by example 1393:Extensible 1267:Concurrent 1243:Production 1230:Templating 1210:Simulation 1195:Scientific 1115:Spacecraft 1043:Constraint 1038:Answer set 990:Flow-based 890:comparison 885:Functional 857:Persistent 821:comparison 786:Procedural 758:Structured 749:Imperative 651:References 636:(contrast) 590:See also: 575:invariants 325:collection 297:subtyping. 248:extensions 221:invariants 194:definition 80:newspapers 1613:Low-level 1382:Inductive 1378:Automatic 1200:Scripting 899:Recursive 693:7 October 671:7 October 602:Smalltalk 596:Although 438:ϕ 357:ϕ 321:subtyping 274:hierarchy 206:structure 198:blueprint 1721:Category 1678:See also 1628:Esoteric 1601:Compiled 1596:Assembly 1535:Subjects 1525:Literate 1515:Features 1470:Template 1465:Symbolic 1437:Bayesian 1417:Hygienic 1277:parallel 1156:Modeling 1151:Low-code 1126:End-user 1063:Ontology 995:Reactive 982:Dataflow 628:See also 580:identity 485:of type 428:. Then 404:of type 315:, where 307:Critique 226:cohesion 202:instance 185:identity 173:behavior 1591:Machine 1490:Aspects 1398:Generic 1388:Dynamic 1247:Pattern 1225:Tactile 1190:Quantum 1180:filters 1111:Command 1010:Streams 1005:Signals 776:Modular 555:⁠ 535:⁠ 531:⁠ 511:⁠ 507:⁠ 487:⁠ 483:⁠ 463:⁠ 459:⁠ 430:⁠ 426:⁠ 406:⁠ 402:⁠ 382:⁠ 378:⁠ 349:⁠ 285:lattice 179:methods 155:objects 150:classes 94:scholar 1661:Fourth 1651:Second 1253:Visual 1220:System 1105:Action 929:Strict 620:, and 598:Simula 509:where 347:: Let 182:) and 96:  89:  82:  75:  67:  1666:Fifth 1656:Third 1646:First 1584:Level 1530:Roles 1413:Macro 1176:Pipes 1096:Array 1073:Query 1025:Logic 934:GADTs 924:Total 847:Agent 196:, or 190:class 167:state 101:JSTOR 87:books 1178:and 825:list 695:2012 673:2012 614:Java 336:and 279:tree 73:news 1083:DSL 610:C++ 606:PHP 295:or 161:). 153:of 56:by 1723:: 1447:, 1443:, 1439:, 1245:, 1241:, 970:, 961:, 840:, 836:, 823:, 624:. 618:C# 616:, 612:, 608:, 557:. 303:. 1569:e 1562:t 1555:v 1451:) 1435:( 1419:) 1415:( 1384:) 1380:( 1306:) 1302:( 1274:, 1269:, 1249:) 1237:( 1117:) 1113:( 1107:) 1103:( 1049:) 1045:( 1001:) 997:( 910:) 906:( 892:) 888:( 827:) 819:( 742:) 738:( 728:e 721:t 714:v 697:. 675:. 543:T 519:S 495:S 471:y 447:) 444:y 441:( 414:T 390:x 366:) 363:x 360:( 270:. 263:, 224:( 123:) 117:( 112:) 108:( 98:· 91:· 84:· 77:· 50:. 20:)

Index

Class-based

verification
improve this article
adding citations to reliable sources
"Class-based programming"
news
newspapers
books
scholar
JSTOR
Learn how and when to remove this message
object-oriented programming
inheritance
classes
objects
prototype-based programming
state
behavior
methods
identity
class
definition
blueprint
instance
structure
Encapsulation
invariants
cohesion
Inheritance

Text is available under the Creative Commons Attribution-ShareAlike License. Additional terms may apply.