\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Srabudc} \pdfinfo{ /Title (grundbegriffe-programmieren.pdf) /Creator (Cheatography) /Author (Srabudc) /Subject (Grundbegriffe Programmieren Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{0064A6} \definecolor{LightBackground}{HTML}{EFF5F9} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Grundbegriffe Programmieren Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Srabudc} via \textcolor{DarkBackground}{\uline{cheatography.com/84490/cs/19964/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Srabudc \\ \uline{cheatography.com/srabudc} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 19th August, 2019.\\ Updated 26th September, 2021.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{x{2.72 cm} x{5.28 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Objekt ({\emph{object}})}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Objektinstanz} & {\emph{Instanz einer Klasse}} oder auch {\emph{erzeugtes Objekt}} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Zustand eines Objekts & Alle aktuellen Werte der Instanzvariablen einer Objektinstanz \tn % Row Count 5 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Der Begriff {\emph{Objekt}} bezeichnet eine {\bf{Instanz einer Klasse}}.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.92 cm} x{4.08 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Klasse ({\emph{class}})}} \tn % Row 0 \SetRowColor{LightBackground} Kopf einer Klasse & enth{\"a}lt unter anderem den Namen der Klasse \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Innenteil der Klasse & enth{\"a}lt die Implementierung der Klasse mit\{\{nl\}\}* Datenfeldern ({\emph{fields}})\{\{nl\}\}* Konstruktoren ({\emph{constructors}})\{\{nl\}\}* Methoden ({\emph{methods}}) \tn % Row Count 11 (+ 8) % Row 2 \SetRowColor{LightBackground} Deklaration & Definition der Datenfelder \tn % Row Count 13 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{Zugriffsmodifikator} ({\emph{access modifier}}) & Der Zugriffsmodifikator bestimmt die Sichtbarkeit. Verwendet werden oft `private` oder `public`. \tn % Row Count 18 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Die Klasse beschreibt eine bestimmte Art von Objekten. \newline Eine Klasse bestimmt, welche {\bf{Methoden}} und {\bf{Datenfelder}} eine {\bf{Objektinstanz}} haben wird. Sie \{\{noshy\}\}"existiert" nur einmal als Vorgabe der Struktur (Bauplan / Formular). \newline Es k{\"o}nnen beliebig viele {\bf{Objektinstanzen}} basierend auf der Definition der Klasse erstellt werden.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.44 cm} x{6.56 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Datentypen}} \tn % Row 0 \SetRowColor{LightBackground} `int` & ganze Zahl, `-2\textasciicircum{}31\textasciicircum{}` bis `2\textasciicircum{}31\textasciicircum{}-1` \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{`String`} & Text \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} \seqsplit{`float`} & Fliesskommazahl mit beschr{\"a}nkter Genauigkeit \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} \seqsplit{`double`} & Fliesskommazahl mit h{\"o}herer Genauigkeit \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} \seqsplit{`boolean`} & `true` oder `false` \tn % Row Count 10 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Für Java sind die Datentypen im Kapitel~4 der \{\{link="https://docs.oracle.com/javase/specs/jls/se17/html/jls-4.html"\}\}The Java® Language Specification\{\{/link\}\} definiert.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.4 cm} x{5.6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Lebensdauer von ...}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Klassenvariablen} & ist für die Programmausführung unbeschr{\"a}nkt \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{Instanzvariablen} & ist auf die Lebenszeit der Objektinstanz beschr{\"a}nkt \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Parametern & ist auf die Ausführungszeit der Methode beschr{\"a}nkt \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} lokalen Variablen & ist auf die Ausfürhrungszeit des Code-Blocks beschr{\"a}nkt \tn % Row Count 9 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{1.84 cm} x{6.16 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Datenfelder ({\emph{fields}})}} \tn % Row 0 \SetRowColor{LightBackground} \seqsplit{Deklaration} & Definition der Datenfelder ({\emph{field declaration}}) \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \seqsplit{Sichtbarkeit} & Datenfelder sind in der Regel `private` und damit nur innerhalb der eigenen Klasse direkt zug{\"a}nglich \tn % Row Count 6 (+ 4) % Row 2 \SetRowColor{LightBackground} Attribut & Wird oft als Datenfeld implementiert \tn % Row Count 8 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{`private String title = "Ein erster Titel";` \newline Siehe auch {\bf{Variable}}.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{Konstruktoren ({\emph{constructors}})}} \tn \SetRowColor{white} \mymulticolumn{1}{x{8.4cm}}{Die Konstruktoren setzen den {\bf{Anfangszustand eines Objekts}} (initialisieren das Objekt). Der Aufbau ist {\bf{{\"a}hnlich der einer Methode}} und die Sichtbarkeit ist in der Regel `public`. \newline % Row Count 4 (+ 4) Der Name des Konstruktors muss der Klassenname sein. Im Gegensatz zu Methoden haben Konstruktoren keinen Rückgabewert.% Row Count 7 (+ 3) } \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{`public Fraction(int numerator, int denominator)`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2 cm} x{6 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Methoden ({\emph{methods}})}} \tn % Row 0 \SetRowColor{LightBackground} Methoden & sind für die Interaktion mit einem Objekt \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Parameter & sind Werte, die an eine Methode (oder Konstruktor) übergeben werden \tn % Row Count 5 (+ 3) % Row 2 \SetRowColor{LightBackground} Signatur & umfasst den Methodennamen und die Parameter einer Methode.\{\{nl\}\}Viele Sprachen unterstützen beliebig viele Parameter und maximal einen Rückgabewert. \tn % Row Count 10 (+ 5) % Row 3 \SetRowColor{white} \seqsplit{Methodenkopf} & Enth{\"a}lt neben der Signatur auch den Rückgabewert und die Sichtbarkeit, z.B. `private int doit();` \tn % Row Count 14 (+ 4) % Row 4 \SetRowColor{LightBackground} \seqsplit{Rückgabewert} & = Aufrufergebnis \tn % Row Count 16 (+ 2) % Row 5 \SetRowColor{white} Datentyp & gibt den Wertebereich von Parametern und Rückgabewert vor\{\{nl\}\}Beispiele sind `int`, `boolean`, `...` und Klassen \tn % Row Count 20 (+ 4) % Row 6 \SetRowColor{LightBackground} `void` & wird im Programmcode an der Stelle eines Datentyps bei Rückgabewert angegeben, wenn eine Methode keinen Rückgabewert liefern wird \tn % Row Count 25 (+ 5) % Row 7 \SetRowColor{white} \seqsplit{Inspektoren} & Sondierende Methoden. Beschr{\"a}nkt auf ein Datenfeld sind es Getter-Methoden, z.B. `getPrice` \tn % Row Count 29 (+ 4) % Row 8 \SetRowColor{LightBackground} Mutatoren & Ver{\"a}ndernde Methoden. Beschr{\"a}nkt auf ein Datenfeld sind es Setter-Methoden, z.B. `setPrice` \tn % Row Count 33 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{new page}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.92 cm} x{4.08 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Parameter}} \tn % Row 0 \SetRowColor{LightBackground} aktueller Parameter & Beim Aufruf übergebener Wert. Zum Beispiel `500` in \{\{nl\}\}`new \seqsplit{Ticketautomat(500);`} \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} formaler Parameter ({\emph{formal parameter}}) & Definierter Name des Parameters. Zum Beispiel `ticketpreis` in `public Ticketautomat(int ticketpreis);` \tn % Row Count 11 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{* Werden durch Komma getrennt zwischen Klammern "(" und ")" im Kopf des Konstruktors oder der Methode definiert \newline * haben einen Namen und einen Datentyp \newline `int diceNumber, Colour diceColour`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.2 cm} x{4.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Namensgebung}} \tn % Row 0 \SetRowColor{LightBackground} Datenfelder & Beginnen mit Buchstaben, gefolgt von Buchstaben, Zahlen und "\_" (kein "-"). \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} Clean Code für Datenfelder & Mit Kleinbuchstaben beginnen und Camel Case verwenden. \{\{nl\}\}`reifendruck`, `koerpergroesse`, \{\{nl\}\}`geldEinbezahlt`, `preisInFranken` \tn % Row Count 10 (+ 6) % Row 2 \SetRowColor{LightBackground} Methodennamen & Verb, beginnt mit Kleinbuchstaben.\{\{nl\}\} `moveLeft`, `print` \tn % Row Count 13 (+ 3) % Row 3 \SetRowColor{white} Setter-Methoden & Methoden, die typischerweise ein Datenfeld auf einen neuen Wert setzten.\{\{nl\}\}`setColour`, `setName` \tn % Row Count 18 (+ 5) % Row 4 \SetRowColor{LightBackground} Getter-Methoden & Methoden, die typischerweise den Wert eines Datenfelds abfragen.\{\{nl\}\}`getName`, `isValid` \tn % Row Count 22 (+ 4) % Row 5 \SetRowColor{white} Konstanten & Alles Grossbuchstaben und "`\_`".\{\{nl\}\}`MAX\_RADIUS`, `FIRST\_PLAYER` \tn % Row Count 25 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{2.56 cm} x{5.44 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Kommentar ({\emph{comment}})}} \tn % Row 0 \SetRowColor{LightBackground} Einfache Kommentare & Bis zum Zeilenende mit `//` ({\emph{end-of-line comment}}) oder über mehrere Zeilen mit `/* ... */` ({\emph{traditional comment}}) \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} \seqsplit{Javadoc-Kommentare} & Beginnen mit zwei Sternen: `/** ... */`\{\{nl\}\}und werden in der Regel für Klassen, Konstruktoren und public Methoden geschrieben. \tn % Row Count 10 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{`int value; // Kommentar in einer Zeile ` \newline `/{\emph{*` \newline ` }} Kommentar für Javadoc` \newline ` */`} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{X} \SetRowColor{DarkBackground} \mymulticolumn{1}{x{8.4cm}}{\bf\textcolor{white}{break column}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{1}{x{8.4cm}}{} \tn % Row Count 0 (+ 0) \hhline{>{\arrayrulecolor{DarkBackground}}-} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.84 cm} x{4.16 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Variable ({\emph{variable}})}} \tn % Row 0 \SetRowColor{LightBackground} Datenfelder & sind {\bf{Instanzvariablen}} oder {\bf{Klassenvariablen}} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Instanzvariable ({\emph{instance variable}}) & existiert pro Objekt und ist durch das Fehlen des Schlüsselwortes `static` als Instanzvariable definiert\{\{nl\}\}`private String name;` \tn % Row Count 10 (+ 7) % Row 2 \SetRowColor{LightBackground} Klassenvariable ({\emph{class variable}}) & existiert nur einmal und wird mit dem Schlüsselwort `static` als Klassenvariable gekennzeichnet\{\{nl\}\}`public static int size;` \tn % Row Count 17 (+ 7) % Row 3 \SetRowColor{white} Parameter ({\emph{parameters}}) & werden bei Methoden oder Konstruktoren übergeben \tn % Row Count 20 (+ 3) % Row 4 \SetRowColor{LightBackground} lokale Variablen ({\emph{Local variables}}) & werden in einem Code-{\bf{Block}} (z.B. innerhalb einer Methode) definiert und sind nur innerhalb dieses Blocks verfügbar \tn % Row Count 26 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{Variablen {\bf{speichern Daten}} und haben einen Datentyp, siehe \{\{link="https://docs.oracle.com/javase/specs/jls/se17/html/jls-4.html\#jls-4.12.3"\}\}{\emph{Kinds of variables}} in der JLS\{\{/link\}\}} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}